@@ -10,8 +10,8 @@ class ChartComponent extends React.Component {
1010
1111 static propTypes = {
1212 data : PropTypes . oneOfType ( [
13- PropTypes . object ,
14- PropTypes . func
13+ PropTypes . object ,
14+ PropTypes . func
1515 ] ) . isRequired ,
1616 getDatasetAtEvent : PropTypes . func ,
1717 getElementAtEvent : PropTypes . func ,
@@ -98,9 +98,9 @@ class ChartComponent extends React.Component {
9898
9999 const nextData = this . transformDataProp ( nextProps ) ;
100100
101- if ( ! isEqual ( this . shadowDataProp , nextData ) ) {
102- return true ;
103- }
101+ if ( ! isEqual ( this . shadowDataProp , nextData ) ) {
102+ return true ;
103+ }
104104
105105 return ! isEqual ( plugins , nextProps . plugins ) ;
106106
@@ -160,36 +160,36 @@ class ChartComponent extends React.Component {
160160 let currentDatasets = ( this . chart_instance . config . data && this . chart_instance . config . data . datasets ) || [ ] ;
161161 const nextDatasets = data . datasets || [ ] ;
162162
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 ) ) ;
193193 const { datasets, ...rest } = data ;
194194
195195 this . chart_instance . config . data = {
0 commit comments