Skip to content

Commit

Permalink
Merge pull request #71 from code4romania/update_stacked_bar
Browse files Browse the repository at this point in the history
Update percentage on map
  • Loading branch information
RaduCStefanescu authored Sep 26, 2020
2 parents bfa2e92 + 9172b44 commit b3203a5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@code4ro/reusable-components",
"version": "0.1.27",
"version": "0.1.28",
"description": "Component library for code4ro",
"keywords": [
"code4ro",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ export const ElectionResultsSummarySection = themable<Props>(
const completeness = electionScopeIsComplete(scope);

const topCandidate = results?.candidates && results.candidates[0];
const votes = topCandidate?.votes;
let percentage = formatPercentage(fractionOf(votes || 0, results?.validVotes || 0));
if (
meta &&
meta.type === "referendum" &&
topCandidate &&
topCandidate.name === "NU AU VOTAT" &&
results &&
results.eligibleVoters
) {
percentage = formatPercentage(fractionOf(topCandidate.votes, results.eligibleVoters));
}

const map = width != null && (
<ElectionMap
Expand All @@ -54,9 +66,7 @@ export const ElectionResultsSummarySection = themable<Props>(
>
{topCandidate && (
<div className={classes.mapOverlay}>
<div className={classes.mapOverlayPercentage}>
{formatPercentage(fractionOf(topCandidate.votes, results?.validVotes || 0))}
</div>
<div className={classes.mapOverlayPercentage}>{percentage}</div>
<div className={classes.mapOverlayLabel}>{topCandidate.shortName || topCandidate.name}</div>
</div>
)}
Expand Down

1 comment on commit b3203a5

@vercel
Copy link

@vercel vercel bot commented on b3203a5 Sep 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.