Skip to content

Commit

Permalink
Merge pull request #34 from Petrosdevri/33-filter-results
Browse files Browse the repository at this point in the history
Filtered results
  • Loading branch information
Petrosdevri authored Jun 7, 2024
2 parents ef31ae9 + 948220a commit 8c41f7c
Showing 1 changed file with 36 additions and 32 deletions.
68 changes: 36 additions & 32 deletions src/pages/Results/Results.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,46 @@ export default function Results({nd, syriza, pasok, kke, spartiates, el, niki, p
const seatDistribution = location.state.seatDistribution;
const partyColors = ['#1D6EC8', '#CC1C24', '#00793A', '#DF251C', '#E4B365', '#8DBEE2', '#BD552C', '#972490', '#EB4326', '#16459A', '#EB8C1E', '#509E2F', '#1B395A', '#D82F33', '#F2D308', '#D7062C'];

const barData = [{party: 'ΝΔ', percentage: nd, fill: partyColors[0]},
{party: 'ΣΥΡΙΖΑ', percentage: syriza, fill: partyColors[1]},
{party: 'ΠΑΣΟΚ', percentage: pasok, fill: partyColors[2]},
{party: 'ΚΚΕ', percentage: kke, fill: partyColors[3]},
{party: 'ΣΠ', percentage: spartiates, fill: partyColors[4]},
{party: 'ΕΛ', percentage: el, fill: partyColors[5]},
{party: 'ΝΙΚΗ', percentage: niki, fill: partyColors[6]},
{party: 'ΠΕ', percentage: pe, fill: partyColors[7]},
{party: 'ΜΕΡΑ25', percentage: mera25, fill: partyColors[8]},
{party: 'ΕΠΑΜ', percentage: epam, fill: partyColors[9]},
{party: 'ΕΔ', percentage: ed, fill: partyColors[10]},
{party: 'ΟΠ', percentage: op, fill: partyColors[11]},
{party: 'ΠΣ', percentage: ps, fill: partyColors[12]},
{party: 'ΑΝΤΑΡΣΥΑ', percentage: antarsya, fill: partyColors[13]},
{party: 'ΕΚ', percentage: ek, fill: partyColors[14]},
{party: 'ΚΚΕ Μ-Λ', percentage: kkeml, fill: partyColors[15]}];
const barData = [
{party: 'ΝΔ', percentage: nd, fill: partyColors[0]},
{party: 'ΣΥΡΙΖΑ', percentage: syriza, fill: partyColors[1]},
{party: 'ΠΑΣΟΚ', percentage: pasok, fill: partyColors[2]},
{party: 'ΚΚΕ', percentage: kke, fill: partyColors[3]},
{party: 'ΣΠ', percentage: spartiates, fill: partyColors[4]},
{party: 'ΕΛ', percentage: el, fill: partyColors[5]},
{party: 'ΝΙΚΗ', percentage: niki, fill: partyColors[6]},
{party: 'ΠΕ', percentage: pe, fill: partyColors[7]},
{party: 'ΜΕΡΑ25', percentage: mera25, fill: partyColors[8]},
{party: 'ΕΠΑΜ', percentage: epam, fill: partyColors[9]},
{party: 'ΕΔ', percentage: ed, fill: partyColors[10]},
{party: 'ΟΠ', percentage: op, fill: partyColors[11]},
{party: 'ΠΣ', percentage: ps, fill: partyColors[12]},
{party: 'ΑΝΤΑΡΣΥΑ', percentage: antarsya, fill: partyColors[13]},
{party: 'ΕΚ', percentage: ek, fill: partyColors[14]},
{party: 'ΚΚΕ Μ-Λ', percentage: kkeml, fill: partyColors[15]}
].filter(p => p.percentage > 0);

const maxPercentage = Math.max(...barData.map(entry => entry.percentage));
const upperHeight = Math.ceil(maxPercentage / 5) * 5;

const pieData = [{party: 'ΝΔ', seats: seatDistribution[0], fill: partyColors[0]},
{party: 'ΣΥΡΙΖΑ', seats: seatDistribution[1], fill: partyColors[1]},
{party: 'ΠΑΣΟΚ', seats: seatDistribution[2], fill: partyColors[2]},
{party: 'ΚΚΕ', seats: seatDistribution[3], fill: partyColors[3]},
{party: 'ΣΠ', seats: seatDistribution[4], fill: partyColors[4]},
{party: 'ΕΛ', seats: seatDistribution[5], fill: partyColors[5]},
{party: 'ΝΙΚΗ', seats: seatDistribution[6], fill: partyColors[6]},
{party: 'ΠΕ', seats: seatDistribution[7], fill: partyColors[7]},
{party: 'ΜΕΡΑ25', seats: seatDistribution[8], fill: partyColors[8]},
{party: 'ΕΠΑΜ', seats: seatDistribution[9], fill: partyColors[9]},
{party: 'ΕΔ', seats: seatDistribution[10], fill: partyColors[10]},
{party: 'ΟΠ', seats: seatDistribution[11], fill: partyColors[11]},
{party: 'ΠΣ', seats: seatDistribution[12], fill: partyColors[12]},
{party: 'ΑΝΤΑΡΣΥΑ', seats: seatDistribution[13], fill: partyColors[13]},
{party: 'ΕΚ', seats: seatDistribution[14], fill: partyColors[14]},
{party: 'ΚΚΕ Μ-Λ', seats: seatDistribution[15], fill: partyColors[15]}];
const pieData = [
{party: 'ΝΔ', seats: seatDistribution[0], fill: partyColors[0]},
{party: 'ΣΥΡΙΖΑ', seats: seatDistribution[1], fill: partyColors[1]},
{party: 'ΠΑΣΟΚ', seats: seatDistribution[2], fill: partyColors[2]},
{party: 'ΚΚΕ', seats: seatDistribution[3], fill: partyColors[3]},
{party: 'ΣΠ', seats: seatDistribution[4], fill: partyColors[4]},
{party: 'ΕΛ', seats: seatDistribution[5], fill: partyColors[5]},
{party: 'ΝΙΚΗ', seats: seatDistribution[6], fill: partyColors[6]},
{party: 'ΠΕ', seats: seatDistribution[7], fill: partyColors[7]},
{party: 'ΜΕΡΑ25', seats: seatDistribution[8], fill: partyColors[8]},
{party: 'ΕΠΑΜ', seats: seatDistribution[9], fill: partyColors[9]},
{party: 'ΕΔ', seats: seatDistribution[10], fill: partyColors[10]},
{party: 'ΟΠ', seats: seatDistribution[11], fill: partyColors[11]},
{party: 'ΠΣ', seats: seatDistribution[12], fill: partyColors[12]},
{party: 'ΑΝΤΑΡΣΥΑ', seats: seatDistribution[13], fill: partyColors[13]},
{party: 'ΕΚ', seats: seatDistribution[14], fill: partyColors[14]},
{party: 'ΚΚΕ Μ-Λ', seats: seatDistribution[15], fill: partyColors[15]}
].filter(p => p.seats > 0);

return (
<div className='results'>
Expand Down

0 comments on commit 8c41f7c

Please sign in to comment.