From bef2caef121b7b6b0300e162bdc1c4aa42a23938 Mon Sep 17 00:00:00 2001 From: Aaron Lindsay Date: Sun, 19 Feb 2017 06:14:28 -0500 Subject: [PATCH] StackedBarChart.js: Don't skip lines in legend --- js/components/StackedBarChart.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/js/components/StackedBarChart.js b/js/components/StackedBarChart.js index ee3764c..5d1c24b 100644 --- a/js/components/StackedBarChart.js +++ b/js/components/StackedBarChart.js @@ -62,7 +62,6 @@ module.exports = React.createClass({ var barWidth = x(0.75); var barStart = x(0.25) + (x(1) - barWidth)/2; - var childId=0; // Add Y axis marks and labels, and initialize positive- and // negativeSum arrays @@ -96,9 +95,9 @@ module.exports = React.createClass({ makeXLabel(i); var legendMap = {}; + var childId=1; for (var child in this.props.report.FlattenedSeries) { if (this.props.report.FlattenedSeries.hasOwnProperty(child)) { - childId++; var childData = this.props.report.FlattenedSeries[child]; var rectClasses = "chart-element chart-color" + (childId % 12); var self = this; @@ -115,7 +114,6 @@ module.exports = React.createClass({ var value = childData[i]; if (value == 0) continue; - legendMap[child] = childId; if (value > 0) { rectHeight = y(value) - y(0); positiveSum[i] += rectHeight; @@ -130,11 +128,15 @@ module.exports = React.createClass({ )); } - bars.push(( - - {seriesBars} - - )); + if (seriesBars.length > 0) { + legendMap[child] = childId; + childId++; + bars.push(( + + {seriesBars} + + )); + } } }