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

Update segment props when receive new props #42

Merged
merged 1 commit into from
Dec 5, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]);
};