From b865bf06bf35fd04e59914932974658b454f48f1 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Wed, 19 Apr 2017 20:50:52 -0700 Subject: [PATCH] Fixed stacking issue introduced in #83 --- chartkick.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/chartkick.js b/chartkick.js index 46bb919b..e504b0d1 100644 --- a/chartkick.js +++ b/chartkick.js @@ -569,18 +569,22 @@ options.xAxis.categories = categories; - var newSeries = []; + var newSeries = [], d2; for (i = 0; i < series.length; i++) { d = []; for (j = 0; j < categories.length; j++) { d.push(rows[categories[j]][i] || 0); } - newSeries.push({ + d2 = { name: series[i].name, - data: d, - stack: series[i].stack ? series[i].stack : null - }); + data: d + } + if (series[i].stack) { + d2.stack = series[i].stack; + } + + newSeries.push(d2); } options.series = newSeries; @@ -1231,7 +1235,6 @@ var dataset = { label: s.name, data: rows2[i], - stack: s.stack ? s.stack : null, fill: chartType === "area", borderColor: color, backgroundColor: backgroundColor, @@ -1239,6 +1242,10 @@ borderWidth: 2 }; + if (s.stack) { + dataset.stack = s.stack; + } + if (chart.options.curve === false) { dataset.lineTension = 0; }