@@ -10,8 +10,8 @@ class ChartComponent extends React.Component {
10
10
11
11
static propTypes = {
12
12
data : PropTypes . oneOfType ( [
13
- PropTypes . object ,
14
- PropTypes . func
13
+ PropTypes . object ,
14
+ PropTypes . func
15
15
] ) . isRequired ,
16
16
getDatasetAtEvent : PropTypes . func ,
17
17
getElementAtEvent : PropTypes . func ,
@@ -98,9 +98,9 @@ class ChartComponent extends React.Component {
98
98
99
99
const nextData = this . transformDataProp ( nextProps ) ;
100
100
101
- if ( ! isEqual ( this . shadowDataProp , nextData ) ) {
102
- return true ;
103
- }
101
+ if ( ! isEqual ( this . shadowDataProp , nextData ) ) {
102
+ return true ;
103
+ }
104
104
105
105
return ! isEqual ( plugins , nextProps . plugins ) ;
106
106
@@ -160,36 +160,36 @@ class ChartComponent extends React.Component {
160
160
let currentDatasets = ( this . chart_instance . config . data && this . chart_instance . config . data . datasets ) || [ ] ;
161
161
const nextDatasets = data . datasets || [ ] ;
162
162
163
- // use the key provider to work out which series have been added/removed/changed
164
- const currentDatasetKeys = currentDatasets . map ( this . props . datasetKeyProvider ) ;
165
- const nextDatasetKeys = nextDatasets . map ( this . props . datasetKeyProvider ) ;
166
- const newDatasets = nextDatasets . filter ( d => currentDatasetKeys . indexOf ( this . props . datasetKeyProvider ( d ) ) === - 1 ) ;
167
-
168
- // process the updates (via a reverse for loop so we can safely splice deleted datasets out of the array
169
- for ( let idx = currentDatasets . length - 1 ; idx >= 0 ; idx -= 1 ) {
170
- const currentDatasetKey = this . props . datasetKeyProvider ( currentDatasets [ idx ] ) ;
171
- if ( nextDatasetKeys . indexOf ( currentDatasetKey ) === - 1 ) {
172
- // deleted series
173
- currentDatasets . splice ( idx , 1 ) ;
174
- } else {
175
- const retainedDataset = find ( nextDatasets , d => this . props . datasetKeyProvider ( d ) === currentDatasetKey ) ;
176
- if ( retainedDataset ) {
177
- // update it in place if it is a retained dataset
178
- currentDatasets [ idx ] . data . splice ( retainedDataset . data . length ) ;
179
- retainedDataset . data . forEach ( ( point , pid ) => {
180
- currentDatasets [ idx ] . data [ pid ] = retainedDataset . data [ pid ] ;
181
- } ) ;
182
- const { data, ...otherProps } = retainedDataset ;
183
- currentDatasets [ idx ] = {
184
- data : currentDatasets [ idx ] . data ,
185
- ...currentDatasets [ idx ] ,
186
- ...otherProps
187
- } ;
188
- }
189
- }
190
- }
191
- // finally add any new series
192
- newDatasets . forEach ( d => currentDatasets . push ( d ) ) ;
163
+ // use the key provider to work out which series have been added/removed/changed
164
+ const currentDatasetKeys = currentDatasets . map ( this . props . datasetKeyProvider ) ;
165
+ const nextDatasetKeys = nextDatasets . map ( this . props . datasetKeyProvider ) ;
166
+ const newDatasets = nextDatasets . filter ( d => currentDatasetKeys . indexOf ( this . props . datasetKeyProvider ( d ) ) === - 1 ) ;
167
+
168
+ // process the updates (via a reverse for loop so we can safely splice deleted datasets out of the array
169
+ for ( let idx = currentDatasets . length - 1 ; idx >= 0 ; idx -= 1 ) {
170
+ const currentDatasetKey = this . props . datasetKeyProvider ( currentDatasets [ idx ] ) ;
171
+ if ( nextDatasetKeys . indexOf ( currentDatasetKey ) === - 1 ) {
172
+ // deleted series
173
+ currentDatasets . splice ( idx , 1 ) ;
174
+ } else {
175
+ const retainedDataset = find ( nextDatasets , d => this . props . datasetKeyProvider ( d ) === currentDatasetKey ) ;
176
+ if ( retainedDataset ) {
177
+ // update it in place if it is a retained dataset
178
+ currentDatasets [ idx ] . data . splice ( retainedDataset . data . length ) ;
179
+ retainedDataset . data . forEach ( ( point , pid ) => {
180
+ currentDatasets [ idx ] . data [ pid ] = retainedDataset . data [ pid ] ;
181
+ } ) ;
182
+ const { data, ...otherProps } = retainedDataset ;
183
+ currentDatasets [ idx ] = {
184
+ data : currentDatasets [ idx ] . data ,
185
+ ...currentDatasets [ idx ] ,
186
+ ...otherProps
187
+ } ;
188
+ }
189
+ }
190
+ }
191
+ // finally add any new series
192
+ newDatasets . forEach ( d => currentDatasets . push ( d ) ) ;
193
193
const { datasets, ...rest } = data ;
194
194
195
195
this . chart_instance . config . data = {
0 commit comments