Skip to content

Commit

Permalink
added coming soon flag, cleaned some breaking changes with the pie chart
Browse files Browse the repository at this point in the history
  • Loading branch information
arnavchopraavataar committed Nov 3, 2023
1 parent b26e2f7 commit d988855
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
25 changes: 16 additions & 9 deletions frontend/components/analytics/AnalyticsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ const AnalyticsCardContent = ({
optionData?.options?.forEach((x) => {
total += x.vote_count
})
const targetPopulationsData = data?.poll_statistics
const targetPopulationsData = data?.poll_statistics || []
const schoolVotes = {}
const yearVotes = {}

Expand All @@ -179,7 +179,7 @@ const AnalyticsCardContent = ({
}
if (item.breakdown && item.breakdown.YEAR) {
const years = item.breakdown.YEAR
Object.keys(year).forEach((school) => {
Object.keys(year).forEach((year) => {
if (yearVotes[year]) {
yearVotes[year] += years[year]
} else {
Expand All @@ -190,21 +190,28 @@ const AnalyticsCardContent = ({
})

let totalVoteCount = 0
data.poll_statistics.map((opt: any, idx: number) => {
data?.poll_statistics?.map((opt: any, idx: number) => {
totalVoteCount += optionData.options[idx]?.vote_count || 0
})

// TODO: add loading state?
return (
<AnalyticsBodyWrapper>
{error}
{data.poll_statistics.length > 0 && !isLoading && (
{'title' in content && (
<div
style={{
display: 'flex',
justifyContent: 'center',
fontSize: '1rem',
fontWeight: '500',
}}
>
Coming Soon!
</div>
)}
{'question' in content && data.poll_statistics.length > 0 && !isLoading && (
<div style={{ display: 'flex' }}>
{/* <div style={{ marginRight: 20 }}>
<ViewsComponent />
<div style={{ height: 10 }} />
<ViewsComponent />
</div> */}
<PrettyBorderWrapper>
<FlexCentered>
<div
Expand Down
12 changes: 11 additions & 1 deletion frontend/components/analytics/PieChartComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const SimplePieChart = ({ schoolData, yearData, mode, uniqueVotes }) => {
name: school,
value: schoolData[school],
}))
return (
return Object.keys(dataToUse).length !== 0 ? (
<div
style={{
position: 'relative',
Expand Down Expand Up @@ -56,6 +56,16 @@ const SimplePieChart = ({ schoolData, yearData, mode, uniqueVotes }) => {
<Tooltip />
</PieChart>
</div>
) : (
<div
style={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}}
>
No data available yet.
</div>
)
}

Expand Down

0 comments on commit d988855

Please sign in to comment.