Skip to content

Commit

Permalink
hide polled %ge and total votes column
Browse files Browse the repository at this point in the history
  • Loading branch information
Yujith Isura authored and Yujith Isura committed Nov 18, 2019
1 parent 00dd6df commit 6ccb7c5
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 13 deletions.
4 changes: 3 additions & 1 deletion src/elections/DataUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,12 @@ export function getAggregateStats(results, mapFieldPrefix) {
* @example 0.54321 -> 54.3%
*/
export function formatPercent(x) {
if(x != null){
return x.toLocaleString('en-us', {
style: 'percent',
minimumFractionDigits: 2,
});
});}

}

/**
Expand Down
79 changes: 67 additions & 12 deletions src/elections/ResultsTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ export default class ResultsTable extends Component {
key={keyPrefix + 'header-total-polled'}
text="Total Polled"
/>,
<CellHeader
key={keyPrefix + 'header-registed-votes'}
text="Registered Votes"
/>,
// <CellHeader
// key={keyPrefix + 'header-registed-votes'}
// text="Registered Votes"
// />,
])
}</tr>
);
Expand Down Expand Up @@ -144,7 +144,7 @@ export default class ResultsTable extends Component {
);
});
const otherPartyVotes = totalValid - displayPartyVotes;

if (label === 'Final Results') {
className += ' tr-totals';
}
Expand Down Expand Up @@ -186,12 +186,14 @@ export default class ResultsTable extends Component {
<CellNumberPercent
key={key + '-total-polled-votes'}
value={totalPolled}
valuePercent={totalPolled / totalElectors}
/>,
<CellNumber
key={key + '-total-registered-voters'}
value={totalElectors}
valuePercent={null}
// valuePercent={totalPolled / totalElectors}

/>,
// <CellNumber
// key={key + '-total-registered-voters'}
// value={totalElectors}
// />,
])}
</tr>
);
Expand Down Expand Up @@ -231,7 +233,7 @@ export default class ResultsTable extends Component {
votesByParty,
totalValid,
);

const _tableRowList = results.map(
function(result, i) {
const key = 'table-row-' + i;
Expand Down Expand Up @@ -260,6 +262,12 @@ export default class ResultsTable extends Component {
if (childLabel === this.props.activeLabel) {
className += ' tr-selected';
}

// const _tableRowList = results.map(
// function(result, i) {
// if (childLabel === 'Postal Votes') {
// postalVotes = totalElectors;
// }

return this.renderRow(
className,
Expand All @@ -280,6 +288,53 @@ export default class ResultsTable extends Component {
}.bind(this),
);


// var postalVotes = 0;
// results.map = (d) => {

// const childLabel = d.childLabelField;

// if (childLabel === 'Postal Votes') {
// postalVotes = d.electors;
// }
// return postalVotes;
// }


// results.forEach(function(d) {
// const childLabel = result[childLabelField];
// if (d.childLabel === "Postal Votes" ) {
// postalVotes = d.electors;
// }
// });


debugger;
// results.map = (result) => {
// const childLabel = result.childLabelField;
// if (childLabel === "Postal Votes" ) {
// postalVotes = result.electors;
// }else{
// postalVotes = "result.electors";
// }
// }

const postalVotes = results.map(
function(result, i) {
const childLabel = result[childLabelField];

let Electors = '';
if (result.pd_name === "Postal Votes") {
Electors = result.electors;
}

return Electors;

}.bind(this),
);



const _totalsRow = (this.props.showTotals) ?
this.renderRow(
'tr-totals',
Expand All @@ -294,7 +349,7 @@ export default class ResultsTable extends Component {
totalValid,
totalRejected,
totalPolled,
totalElectors,
totalElectors + "ttfghfghss" + postalVotes,
) : null;


Expand Down

0 comments on commit 6ccb7c5

Please sign in to comment.