@@ -20,7 +20,8 @@ import {
2020 polyfillTitleEvent ,
2121 polyfillDescriptionEvent ,
2222} from './plots/core/polyfill' ;
23- import { debounce , isArray , isFunction , isNil , isEqual } from '@antv/util' ;
23+ import { debounce , isArray , isFunction , isNil } from '@antv/util' ;
24+ import isEqual from './utils/isEqual' ;
2425import warn from 'warning' ;
2526
2627// 国际化处理
@@ -100,13 +101,13 @@ class BasePlot extends React.Component<any> {
100101 }
101102 polyfillEvents ( this . g2Instance , { } , this . props ) ;
102103 this . g2Instance . data = this . props . data ;
103- this . preConfig = pickWithout ( this . props , [
104+ this . preConfig = cloneDeep ( pickWithout ( this . props , [
104105 ...REACT_PIVATE_PROPS ,
105106 'container' ,
106107 'PlotClass' ,
107108 'onGetG2Instance' ,
108109 'data' ,
109- ] ) ;
110+ ] ) ) ;
110111 }
111112 componentDidUpdate ( prevProps ) {
112113 if ( this . props . children && this . g2Instance . chart ) {
@@ -149,11 +150,12 @@ class BasePlot extends React.Component<any> {
149150 this . g2Instance . destroy ( ) ;
150151 this . initInstance ( ) ;
151152 this . g2Instance . render ( ) ;
152- } else if ( this . diffConfig ( ) ) {
153- // 对比options是否更新
154- if ( ! isEqual ( currentConfig , this . preConfig ) ) {
155- this . g2Instance . update ( currentConfig ) ;
156- }
153+ } else if ( this . diffConfig ( ) ) {
154+ // options更新
155+ this . g2Instance . update ( {
156+ ...currentConfig ,
157+ data : this . props . data
158+ } ) ;
157159 } else if ( this . diffData ( ) ) {
158160 this . g2Instance . changeData ( this . props . data ) ;
159161 }
@@ -180,7 +182,7 @@ class BasePlot extends React.Component<any> {
180182 'onGetG2Instance' ,
181183 'data' ,
182184 ] ) ;
183- return ! shallowEqual ( preConfig , currentConfig ) ;
185+ return ! isEqual ( preConfig , currentConfig ) ;
184186 }
185187 diffData ( ) {
186188 // 只有数据更新就不重绘,其他全部直接重新创建实例。
0 commit comments