Skip to content

Commit 26b4d9d

Browse files
tobbeejerairrest
authored andcommitted
Make updateChart robust to missing data in dataset. Relevant for other update mechanisms as in chartjs-plugin-streaming. (#434)
1 parent 177aa1e commit 26b4d9d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ class ChartComponent extends React.Component {
207207
const current =
208208
currentDatasetsIndexed[this.props.datasetKeyProvider(next)];
209209

210-
if (current && current.type === next.type) {
210+
if (current && current.type === next.type && next.data) {
211+
// Be robust to no data. Relevant for other update mechanisms as in chartjs-plugin-streaming.
211212
// The data array must be edited in place. As chart.js adds listeners to it.
212213
current.data.splice(next.data.length);
213214
next.data.forEach((point, pid) => {

0 commit comments

Comments
 (0)