From 5a255e03d60a8d4866464b60afa5dff72cd32dac Mon Sep 17 00:00:00 2001
From: Derek Eder
Date: Tue, 22 Mar 2022 22:19:40 -0500
Subject: [PATCH 2/6] linting
---
src/components/singlebar.js | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/components/singlebar.js b/src/components/singlebar.js
index 9a0368fe..7e7d0bea 100644
--- a/src/components/singlebar.js
+++ b/src/components/singlebar.js
@@ -1,9 +1,9 @@
-import React from "react";
+import React from "react"
import { BarChart, Bar, XAxis, YAxis, LabelList, CartesianGrid } from "recharts"
const getLabel=(props, label) => { return label }
-export default function SingleBarChart({emissions_data}) {
+export default function SingleBarChart ({emissions_data}) {
return (
getLabel(props, 'Dumps, Farms, Industrial & Other')} position="insideTopLeft" />
-
+
getLabel(props, 'Transportation')} position="insideTopLeft" />
From 7930553046eb3501f6eb10d94869f38963f1b0b3 Mon Sep 17 00:00:00 2001
From: Dylan
Date: Wed, 23 Mar 2022 19:44:03 -0500
Subject: [PATCH 3/6] Content change to valueAccessor on label list
---
src/components/singlebar.js | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/components/singlebar.js b/src/components/singlebar.js
index 7e7d0bea..53cb6323 100644
--- a/src/components/singlebar.js
+++ b/src/components/singlebar.js
@@ -1,9 +1,15 @@
import React from "react"
import { BarChart, Bar, XAxis, YAxis, LabelList, CartesianGrid } from "recharts"
-const getLabel=(props, label) => { return label }
+const getPct = (value, total) => { return Math.round((value/total)*100) }
+const getLabel = (entry, total, field, label) => { return `${label}: ${getPct(entry[field], total)}%` }
export default function SingleBarChart ({emissions_data}) {
+ // sum all emissions fields except year
+ const totalEmissions = Object.entries(emissions_data[0])
+ .filter(([key,_val]) => key !== 'year')
+ .reduce((acc, [_key,val]) => acc + val, 0);
+
return (
- getLabel(props, 'Dumps, Farms, Industrial & Other')} position="insideTopLeft" />
+ getLabel(entry, totalEmissions, 'dumps_farms_industrial_other', 'Dumps, Farms, Industrial & Other')} position="insideTopLeft" />
- getLabel(props, 'Transportation')} position="insideTopLeft" />
+ getLabel(entry, totalEmissions, 'transportation', 'Transportation')} position="insideTopLeft" />
- getLabel(props, 'Buildings')} position="insideTopLeft" />
+ getLabel(entry, totalEmissions, 'buildings', 'Buildings')} position="insideTopLeft" />
- getLabel(props, 'Dirty Power')} position="insideTopLeft" />
+ getLabel(entry, totalEmissions, 'dirty_power', 'Dirty Power')} position="insideTopLeft" />
)
From 6824876108010f35c80973cf8b712d304509705b Mon Sep 17 00:00:00 2001
From: Dylan
Date: Wed, 23 Mar 2022 20:02:07 -0500
Subject: [PATCH 4/6] Lint
---
src/components/singlebar.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/components/singlebar.js b/src/components/singlebar.js
index 53cb6323..f3fc1ee2 100644
--- a/src/components/singlebar.js
+++ b/src/components/singlebar.js
@@ -8,7 +8,7 @@ export default function SingleBarChart ({emissions_data}) {
// sum all emissions fields except year
const totalEmissions = Object.entries(emissions_data[0])
.filter(([key,_val]) => key !== 'year')
- .reduce((acc, [_key,val]) => acc + val, 0);
+ .reduce((acc, [_key,val]) => acc + val, 0)
return (
Date: Thu, 24 Mar 2022 14:48:32 -0500
Subject: [PATCH 5/6] remove YAxis from home page chart
---
src/components/singlebar.js | 9 ---------
1 file changed, 9 deletions(-)
diff --git a/src/components/singlebar.js b/src/components/singlebar.js
index f3fc1ee2..f4b125a0 100644
--- a/src/components/singlebar.js
+++ b/src/components/singlebar.js
@@ -24,15 +24,6 @@ export default function SingleBarChart ({emissions_data}) {
}}
>
-
getLabel(entry, totalEmissions, 'dumps_farms_industrial_other', 'Dumps, Farms, Industrial & Other')} position="insideTopLeft" />
From 96eba172d4eec317c8dfd35a3ed45728805089eb Mon Sep 17 00:00:00 2001
From: Derek Eder
Date: Thu, 24 Mar 2022 17:08:54 -0500
Subject: [PATCH 6/6] removed unused component references
---
src/components/singlebar.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/components/singlebar.js b/src/components/singlebar.js
index f4b125a0..42929b1f 100644
--- a/src/components/singlebar.js
+++ b/src/components/singlebar.js
@@ -1,5 +1,5 @@
import React from "react"
-import { BarChart, Bar, XAxis, YAxis, LabelList, CartesianGrid } from "recharts"
+import { BarChart, Bar, LabelList, CartesianGrid } from "recharts"
const getPct = (value, total) => { return Math.round((value/total)*100) }
const getLabel = (entry, total, field, label) => { return `${label}: ${getPct(entry[field], total)}%` }