diff --git a/src/components/singlebar.js b/src/components/singlebar.js
index 3f7ec540..42929b1f 100644
--- a/src/components/singlebar.js
+++ b/src/components/singlebar.js
@@ -1,80 +1,41 @@
-import React from "react";
-import {
- BarChart,
- Bar,
- XAxis,
- YAxis,
- LabelList,
- CartesianGrid
-} from "recharts";
+import React from "react"
+import { BarChart, Bar, LabelList, CartesianGrid } from "recharts"
-const barColors = ["#685e4a", "#b7b7b7", "#d9d9d9", "#f3f3f3"];
+const getPct = (value, total) => { return Math.round((value/total)*100) }
+const getLabel = (entry, total, field, label) => { return `${label}: ${getPct(entry[field], total)}%` }
-function getTotal (payload) {
- return payload[0].value + payload[1].value + payload[2].value + payload[3].value
-}
+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)
-function calcPercent (payload, index) {
- return (100 * payload[index].value.toFixed(1) / getTotal(payload)).toFixed(1)
-}
-
-// const renderLabel = (props, text) =>{
-// const { x, y, width, height, value } = props
-// return (
-// {text}: {value}
-// )
-// }
-
-const getLabel=(props, label) => {return label}
-
-
-//Render the stacked bar.
- export default function SingleBarChart({emissions_data}) {
return (
When it comes to solving the climate crisis there's one main thing @@ -57,9 +57,7 @@ const IndexPage = ({data}) => {