1
0
mirror of https://github.com/aclindsa/moneygo.git synced 2024-10-30 07:40:05 -04:00

StackedBarChart.js: Don't skip lines in legend

This commit is contained in:
Aaron Lindsay 2017-02-19 06:14:28 -05:00
parent 1171eeac3f
commit bef2caef12

View File

@ -62,7 +62,6 @@ module.exports = React.createClass({
var barWidth = x(0.75); var barWidth = x(0.75);
var barStart = x(0.25) + (x(1) - barWidth)/2; var barStart = x(0.25) + (x(1) - barWidth)/2;
var childId=0;
// Add Y axis marks and labels, and initialize positive- and // Add Y axis marks and labels, and initialize positive- and
// negativeSum arrays // negativeSum arrays
@ -96,9 +95,9 @@ module.exports = React.createClass({
makeXLabel(i); makeXLabel(i);
var legendMap = {}; var legendMap = {};
var childId=1;
for (var child in this.props.report.FlattenedSeries) { for (var child in this.props.report.FlattenedSeries) {
if (this.props.report.FlattenedSeries.hasOwnProperty(child)) { if (this.props.report.FlattenedSeries.hasOwnProperty(child)) {
childId++;
var childData = this.props.report.FlattenedSeries[child]; var childData = this.props.report.FlattenedSeries[child];
var rectClasses = "chart-element chart-color" + (childId % 12); var rectClasses = "chart-element chart-color" + (childId % 12);
var self = this; var self = this;
@ -115,7 +114,6 @@ module.exports = React.createClass({
var value = childData[i]; var value = childData[i];
if (value == 0) if (value == 0)
continue; continue;
legendMap[child] = childId;
if (value > 0) { if (value > 0) {
rectHeight = y(value) - y(0); rectHeight = y(value) - y(0);
positiveSum[i] += rectHeight; positiveSum[i] += rectHeight;
@ -130,11 +128,15 @@ module.exports = React.createClass({
<rect onClick={rectOnClick} className={rectClasses} x={x(i) + barStart} y={rectY} width={barWidth} height={rectHeight} rx={1} ry={1}/> <rect onClick={rectOnClick} className={rectClasses} x={x(i) + barStart} y={rectY} width={barWidth} height={rectHeight} rx={1} ry={1}/>
)); ));
} }
bars.push(( if (seriesBars.length > 0) {
<g className="chart-series"> legendMap[child] = childId;
{seriesBars} childId++;
</g> bars.push((
)); <g className="chart-series">
{seriesBars}
</g>
));
}
} }
} }