diff --git a/code/06-finished/src/components/Chart/Chart.js b/code/06-finished/src/components/Chart/Chart.js
index e9fb675880..5c8d97c201 100644
--- a/code/06-finished/src/components/Chart/Chart.js
+++ b/code/06-finished/src/components/Chart/Chart.js
@@ -4,8 +4,9 @@ import ChartBar from './ChartBar';
import './Chart.css';
const Chart = (props) => {
- const dataPointValues = props.dataPoints.map(dataPoint => dataPoint.value);
- const totalMaximum = Math.max(...dataPointValues);
+ let total = 0;
+ for(let v of props.dataPoints)
+ total += parseFloat(v.value);
return (
@@ -13,7 +14,7 @@ const Chart = (props) => {
))}
diff --git a/code/06-finished/src/components/Chart/ChartBar.js b/code/06-finished/src/components/Chart/ChartBar.js
index 006be7eb0a..6a4b691656 100644
--- a/code/06-finished/src/components/Chart/ChartBar.js
+++ b/code/06-finished/src/components/Chart/ChartBar.js
@@ -5,8 +5,8 @@ import './ChartBar.css';
const ChartBar = (props) => {
let barFillHeight = '0%';
- if (props.maxValue > 0) {
- barFillHeight = Math.round((props.value / props.maxValue) * 100) + '%';
+ if (props.totalValue > 0) {
+ barFillHeight = Math.round((props.value / props.totalValue) * 100) + '%';
}
return (