From 64720e518def89ae3a67eb8ba9dc8f43c3d02599 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Marques?= Date: Thu, 20 Aug 2015 18:45:56 -0300 Subject: [PATCH] update segment props when receive new props --- lib/core.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/core.js b/lib/core.js index 08a2f17..a2ee2ea 100644 --- a/lib/core.js +++ b/lib/core.js @@ -42,8 +42,10 @@ module.exports = { } else { dataKey = dataKey || dataKeys[chart.name]; updatePoints(nextProps, chart, dataKey); - chart.scale.xLabels = nextProps.data.labels; - chart.scale.calculateXLabelRotation(); + if (chart.scale) { + chart.scale.xLabels = nextProps.data.labels; + chart.scale.calculateXLabelRotation(); + } chart.update(); } }; @@ -95,7 +97,9 @@ var updatePoints = function(nextProps, chart, dataKey) { if (!chart.segments[segmentIndex]) { chart.addData(segment); } else { - chart.segments[segmentIndex].value = segment.value; + Object.keys(segment).forEach(function (key) { + chart.segments[segmentIndex][key] = segment[key]; + }); } }); } else { @@ -121,4 +125,3 @@ var addData = function(nextProps, chart, setIndex, pointIndex) { }); chart.addData(values, nextProps.data.labels[setIndex]); }; -