@@ -74,23 +74,33 @@ var Charts = (function (_Component) {
7474 var onReady = this . props . onReady ;
7575
7676 this . drawChart ( ) ;
77- if ( onReady ) onReady ( this . chart ) ;
77+ if ( onReady ) {
78+ onReady ( this . chart ) ;
79+ }
7880 } ;
7981
8082 Charts . prototype . componentDidUpdate = function componentDidUpdate ( prevProps ) {
8183 var _this = this ;
8284
83- var prevPropsArray = _react2 [ 'default' ] . Children . map ( prevProps . children , function ( preChild ) {
84- return preChild . props ;
85- } ) ;
86- var propsArray = _react2 [ 'default' ] . Children . map ( this . props . children , function ( child ) {
87- return child . props ;
88- } ) ;
89- propsArray . map ( function ( props , index ) {
90- if ( props !== prevPropsArray [ index ] ) {
91- _this . drawChart ( ) ;
85+ if ( this . props . options ) {
86+ if ( prevProps . options !== this . props . options ) {
87+ this . drawChart ( ) ;
9288 }
93- } ) ;
89+ } else {
90+ ( function ( ) {
91+ var prevPropsArray = _react2 [ 'default' ] . Children . map ( prevProps . children , function ( preChild ) {
92+ return preChild . props ;
93+ } ) ;
94+ var propsArray = _react2 [ 'default' ] . Children . map ( _this . props . children , function ( child ) {
95+ return child . props ;
96+ } ) ;
97+ propsArray . map ( function ( props , index ) {
98+ if ( props !== prevPropsArray [ index ] ) {
99+ _this . drawChart ( ) ;
100+ }
101+ } ) ;
102+ } ) ( ) ;
103+ }
94104 } ;
95105
96106 Charts . prototype . componentWillUnmount = function componentWillUnmount ( ) {
@@ -105,10 +115,14 @@ var Charts = (function (_Component) {
105115 } ;
106116
107117 Charts . prototype . drawChart = function drawChart ( ) {
108- console . log ( 2 ) ;
109118 var node = this . refs . chart ;
110- var options = _utilsFilterMap2 [ 'default' ] ( [ 'backgroundColor' , 'animation' , 'calculable' , 'renderAsImage' , 'timeline' , 'title' , 'toolbox' , 'tooltip' , 'legend' , 'dataRange' , 'dataZoom' , 'roamController' , 'grid' , 'color' , 'xAxis' , 'yAxis' , 'series' ] , this . props ) ;
111- this . getChartData ( options ) ;
119+ var options = undefined ;
120+ if ( this . props . options ) {
121+ options = this . props . options ;
122+ } else {
123+ options = _utilsFilterMap2 [ 'default' ] ( [ 'backgroundColor' , 'animation' , 'calculable' , 'renderAsImage' , 'timeline' , 'title' , 'toolbox' , 'tooltip' , 'legend' , 'dataRange' , 'dataZoom' , 'roamController' , 'grid' , 'color' , 'xAxis' , 'yAxis' , 'series' ] , this . props ) ;
124+ this . getChartData ( options ) ;
125+ }
112126 this . chart = _echarts2 [ 'default' ] . init ( node ) ;
113127 this . chart . setOption ( options , this . props . theme ) ;
114128 } ;
0 commit comments