Skip to content
This repository has been archived by the owner on Jul 19, 2019. It is now read-only.

Commit

Permalink
update segment props when receive new props
Browse files Browse the repository at this point in the history
  • Loading branch information
dehbmarques committed Aug 20, 2015
1 parent 6fe5ca9 commit 64720e5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
};
Expand Down Expand Up @@ -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 {
Expand All @@ -121,4 +125,3 @@ var addData = function(nextProps, chart, setIndex, pointIndex) {
});
chart.addData(values, nextProps.data.labels[setIndex]);
};

0 comments on commit 64720e5

Please sign in to comment.