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

Copy across the specified properties of each dataset when updating the chart #98

Closed
Closed
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
10 changes: 9 additions & 1 deletion lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,18 @@ module.exports = {
chart.data.labels = [];

// Adds the datapoints from nextProps
var propsToCopy = ['hidden'];

nextProps.data.datasets.forEach(function(set, setIndex) {
set.data.forEach(function(val, pointIndex) {
chart.data.datasets[setIndex].data[pointIndex] = nextProps.data.datasets[setIndex].data[pointIndex];
});

propsToCopy.forEach(function(prop) {
if (nextProps.data.datasets[setIndex][prop] !== undefined) {
chart.data.datasets[setIndex][prop] = nextProps.data.datasets[setIndex][prop];
}
});
});

// Sets the labels from nextProps
Expand Down Expand Up @@ -118,4 +126,4 @@ module.exports = {

return React.createClass(classData);
}
};
};