@@ -97,6 +97,8 @@ function (_React$Component) {
9797 var currentOptions = this . resolveChartOptions ( nextProps ) ;
9898 var oldOptions = this . oldOptions ;
9999 var optionsUpdatedNatively = [ 'width' , 'height' , 'type' , 'dataFormat' , 'dataSource' , 'events' ] ;
100+ console . log ( 'currentOptions' , currentOptions ) ;
101+ console . log ( 'oldOptions' , oldOptions ) ;
100102 this . checkAndUpdateChartDimensions ( currentOptions , oldOptions ) ;
101103 this . checkAndUpdateChartType ( currentOptions , oldOptions ) ;
102104 this . checkAndUpdateChartData ( currentOptions , oldOptions ) ;
@@ -151,15 +153,22 @@ function (_React$Component) {
151153 var currData = currentOptions . dataSource ;
152154 var oldDataFormat = oldOptions . dataFormat ;
153155 var oldData = oldOptions . dataSource ;
156+ console . log ( {
157+ currDataFormat : currDataFormat ,
158+ oldDataFormat : oldDataFormat
159+ } ) ;
154160
155161 if ( String ( currDataFormat ) . toLowerCase ( ) !== String ( oldDataFormat ) . toLowerCase ( ) ) {
156162 if ( ! utils . isUndefined ( currDataFormat ) && ! utils . isUndefined ( currData ) ) {
157163 this . chartObj . setChartData ( currData , String ( currDataFormat ) . toLowerCase ( ) ) ; // If the chart dataFormat is changed then
158164 // animate the chart to show the changes
159165
160166 this . chartObj . render ( ) ;
167+ return ;
161168 }
162- } else if ( ! this . isSameChartData ( currData , oldData ) ) {
169+ }
170+
171+ if ( ! this . isSameChartData ( currData , oldData ) ) {
163172 if ( ! utils . isUndefined ( currData ) ) {
164173 this . chartObj . setChartData ( currData , // When dataFormat is not given, but data is changed,
165174 // then use 'json' as default dataFormat
@@ -170,11 +179,35 @@ function (_React$Component) {
170179 } , {
171180 key : "isSameChartData" ,
172181 value : function isSameChartData ( currData , oldData ) {
173- if ( utils . isObject ( currData ) && utils . isObject ( oldData ) && ! utils . checkIfDataTableExists ( currData ) && ! utils . checkIfDataTableExists ( oldData ) ) {
174- return utils . isSameObjectContent ( currData , oldData ) ;
175- }
182+ /* TODO
183+ 1. Current has DataStore and Old doesn't
184+ 2. Old has and Current doesn't
185+ 3. Both has, check ref is equal, return false only if not equal
186+ 4. Clone oldData for diff
187+ 5. Clone currentData for diff
188+ 6. return string check.
189+ */
190+ // 1. Current has DataStore and Old doesn't
191+ if ( utils . checkIfDataTableExists ( currData ) && ! utils . checkIfDataTableExists ( oldData ) ) {
192+ return false ;
193+ } // 2. Old has and Current doesn't
194+
195+
196+ if ( ! utils . checkIfDataTableExists ( currData ) && utils . checkIfDataTableExists ( oldData ) ) {
197+ return false ;
198+ } // 3. Both has, check ref is equal, return false only if not equal
199+
200+
201+ if ( utils . checkIfDataTableExists ( currData ) && utils . checkIfDataTableExists ( oldData ) && currData . data !== oldData . data ) {
202+ return false ;
203+ } // 4. Clone oldData for diff
204+
205+
206+ var oldDataStringified = JSON . stringify ( utils . cloneDataSource ( oldData , 'diff' ) ) ; // 5. Clone currentData for diff
207+
208+ var currentDataStringified = JSON . stringify ( utils . cloneDataSource ( currData , 'diff' ) ) ; // 6. return string check.
176209
177- return currData === oldData ;
210+ return oldDataStringified === currentDataStringified ;
178211 }
179212 } , {
180213 key : "checkAndUpdateEvents" ,
@@ -313,6 +346,8 @@ function (_React$Component) {
313346
314347 if ( utils . isObject ( inlineOptions . dataSource ) && ! utils . checkIfDataTableExists ( inlineOptions . dataSource ) ) {
315348 inlineOptions . dataSource = utils . deepCopyOf ( inlineOptions . dataSource ) ;
349+ } else if ( utils . isObject ( inlineOptions . dataSource ) && utils . checkIfDataTableExists ( inlineOptions . dataSource ) ) {
350+ inlineOptions . dataSource = utils . cloneDataSource ( inlineOptions . dataSource , 'clone' ) ;
316351 }
317352
318353 if ( utils . isObject ( inlineOptions . link ) ) {
0 commit comments