11( function webpackUniversalModuleDefinition ( root , factory ) {
22 if ( typeof exports === 'object' && typeof module === 'object' )
3- module . exports = factory ( require ( "Chartjs " ) , require ( "react" ) ) ;
3+ module . exports = factory ( require ( "react " ) , require ( "react-dom" ) , require ( "Chartjs ") ) ;
44 else if ( typeof define === 'function' && define . amd )
5- define ( [ "Chartjs " , "react" ] , factory ) ;
5+ define ( [ "react " , "react-dom" , "Chartjs "] , factory ) ;
66 else if ( typeof exports === 'object' )
7- exports [ "react-chartjs" ] = factory ( require ( "Chartjs " ) , require ( "react" ) ) ;
7+ exports [ "react-chartjs" ] = factory ( require ( "react " ) , require ( "react-dom" ) , require ( "Chartjs ") ) ;
88 else
9- root [ "react-chartjs" ] = factory ( root [ "Chartjs " ] , root [ "React " ] ) ;
10- } ) ( this , function ( __WEBPACK_EXTERNAL_MODULE_8__ , __WEBPACK_EXTERNAL_MODULE_9__ ) {
9+ root [ "react-chartjs" ] = factory ( root [ "React " ] , root [ "ReactDOM" ] , root [ "Chart "] ) ;
10+ } ) ( this , function ( __WEBPACK_EXTERNAL_MODULE_3__ , __WEBPACK_EXTERNAL_MODULE_4__ , __WEBPACK_EXTERNAL_MODULE_5__ ) {
1111return /******/ ( function ( modules ) { // webpackBootstrap
1212/******/ // The module cache
1313/******/ var installedModules = { } ;
@@ -56,20 +56,20 @@ return /******/ (function(modules) { // webpackBootstrap
5656
5757 module . exports = {
5858 Bar : __webpack_require__ ( 1 ) ,
59- Doughnut : __webpack_require__ ( 2 ) ,
60- Line : __webpack_require__ ( 3 ) ,
61- Pie : __webpack_require__ ( 4 ) ,
62- PolarArea : __webpack_require__ ( 5 ) ,
63- Radar : __webpack_require__ ( 6 ) ,
64- createClass : __webpack_require__ ( 7 ) . createClass
59+ Doughnut : __webpack_require__ ( 6 ) ,
60+ Line : __webpack_require__ ( 7 ) ,
61+ Pie : __webpack_require__ ( 8 ) ,
62+ PolarArea : __webpack_require__ ( 9 ) ,
63+ Radar : __webpack_require__ ( 10 ) ,
64+ createClass : __webpack_require__ ( 2 ) . createClass
6565 } ;
6666
6767
6868/***/ } ,
6969/* 1 */
7070/***/ function ( module , exports , __webpack_require__ ) {
7171
72- var vars = __webpack_require__ ( 7 ) ;
72+ var vars = __webpack_require__ ( 2 ) ;
7373
7474 module . exports = vars . createClass ( 'Bar' , [ 'getBarsAtEvent' ] ) ;
7575
@@ -78,50 +78,8 @@ return /******/ (function(modules) { // webpackBootstrap
7878/* 2 */
7979/***/ function ( module , exports , __webpack_require__ ) {
8080
81- var vars = __webpack_require__ ( 7 ) ;
82-
83- module . exports = vars . createClass ( 'Doughnut' , [ 'getSegmentsAtEvent' ] ) ;
84-
85-
86- /***/ } ,
87- /* 3 */
88- /***/ function ( module , exports , __webpack_require__ ) {
89-
90- var vars = __webpack_require__ ( 7 ) ;
91-
92- module . exports = vars . createClass ( 'Line' , [ 'getPointsAtEvent' ] ) ;
93-
94-
95- /***/ } ,
96- /* 4 */
97- /***/ function ( module , exports , __webpack_require__ ) {
98-
99- var vars = __webpack_require__ ( 7 ) ;
100-
101- module . exports = vars . createClass ( 'Pie' , [ 'getSegmentsAtEvent' ] ) ;
102-
103-
104- /***/ } ,
105- /* 5 */
106- /***/ function ( module , exports , __webpack_require__ ) {
107-
108- var vars = __webpack_require__ ( 7 ) ;
109-
110- module . exports = vars . createClass ( 'PolarArea' , [ 'getSegmentsAtEvent' ] ) ;
111-
112-
113- /***/ } ,
114- /* 6 */
115- /***/ function ( module , exports , __webpack_require__ ) {
116-
117- var vars = __webpack_require__ ( 7 ) ;
118-
119- module . exports = vars . createClass ( 'Radar' , [ 'getPointsAtEvent' ] ) ;
120-
121-
122- /***/ } ,
123- /* 7 */
124- /***/ function ( module , exports , __webpack_require__ ) {
81+ var React = __webpack_require__ ( 3 ) ;
82+ var ReactDOM = __webpack_require__ ( 4 ) ;
12583
12684 module . exports = {
12785 createClass : function ( chartType , methodNames , dataKey ) {
@@ -146,7 +104,7 @@ return /******/ (function(modules) { // webpackBootstrap
146104 var extras = [ 'clear' , 'stop' , 'resize' , 'toBase64Image' , 'generateLegend' , 'update' , 'addData' , 'removeData' ] ;
147105 function extra ( type ) {
148106 classData [ type ] = function ( ) {
149- this . state . chart [ name ] . apply ( this . state . chart , arguments ) ;
107+ return this . state . chart [ type ] . apply ( this . state . chart , arguments ) ;
150108 } ;
151109 }
152110
@@ -161,19 +119,23 @@ return /******/ (function(modules) { // webpackBootstrap
161119
162120 classData . componentWillReceiveProps = function ( nextProps ) {
163121 var chart = this . state . chart ;
164- if ( this . props . redraw ) {
122+ if ( nextProps . redraw ) {
165123 chart . destroy ( ) ;
166124 this . initializeChart ( nextProps ) ;
167125 } else {
168126 dataKey = dataKey || dataKeys [ chart . name ] ;
169127 updatePoints ( nextProps , chart , dataKey ) ;
128+ if ( chart . scale ) {
129+ chart . scale . xLabels = nextProps . data . labels ;
130+ chart . scale . calculateXLabelRotation ( ) ;
131+ }
170132 chart . update ( ) ;
171133 }
172134 } ;
173135
174136 classData . initializeChart = function ( nextProps ) {
175- var Chart = __webpack_require__ ( 8 ) ;
176- var el = this . getDOMNode ( ) ;
137+ var Chart = __webpack_require__ ( 5 ) ;
138+ var el = ReactDOM . findDOMNode ( this ) ;
177139 var ctx = el . getContext ( "2d" ) ;
178140 var chart = new Chart ( ctx ) [ chartType ] ( nextProps . data , nextProps . options || { } ) ;
179141 this . state . chart = chart ;
@@ -186,9 +148,11 @@ return /******/ (function(modules) { // webpackBootstrap
186148
187149 // return the canvass element that contains the chart
188150 classData . getCanvass = function ( ) {
189- return this . refs . canvass . getDOMNode ( ) ;
151+ return this . refs . canvass ;
190152 } ;
191153
154+ classData . getCanvas = classData . getCanvass ;
155+
192156 var i ;
193157 for ( i = 0 ; i < extras . length ; i ++ ) {
194158 extra ( extras [ i ] ) ;
@@ -197,7 +161,6 @@ return /******/ (function(modules) { // webpackBootstrap
197161 extra ( methodNames [ i ] ) ;
198162 }
199163
200- var React = __webpack_require__ ( 9 ) ;
201164 return React . createClass ( classData ) ;
202165 }
203166 } ;
@@ -213,33 +176,101 @@ return /******/ (function(modules) { // webpackBootstrap
213176
214177 if ( name === 'PolarArea' || name === 'Pie' || name === 'Doughnut' ) {
215178 nextProps . data . forEach ( function ( segment , segmentIndex ) {
216- chart . segments [ segmentIndex ] . value = segment . value ;
179+ if ( ! chart . segments [ segmentIndex ] ) {
180+ chart . addData ( segment ) ;
181+ } else {
182+ Object . keys ( segment ) . forEach ( function ( key ) {
183+ chart . segments [ segmentIndex ] [ key ] = segment [ key ] ;
184+ } ) ;
185+ }
217186 } ) ;
218187 } else {
188+ while ( chart . scale . xLabels . length > nextProps . data . labels . length ) {
189+ chart . removeData ( ) ;
190+ }
219191 nextProps . data . datasets . forEach ( function ( set , setIndex ) {
220192 set . data . forEach ( function ( val , pointIndex ) {
221- chart . datasets [ setIndex ] [ dataKey ] [ pointIndex ] . value = val ;
193+ if ( typeof ( chart . datasets [ setIndex ] [ dataKey ] [ pointIndex ] ) == "undefined" ) {
194+ addData ( nextProps , chart , setIndex , pointIndex ) ;
195+ } else {
196+ chart . datasets [ setIndex ] [ dataKey ] [ pointIndex ] . value = val ;
197+ }
222198 } ) ;
223199 } ) ;
224200 }
225201 } ;
226202
203+ var addData = function ( nextProps , chart , setIndex , pointIndex ) {
204+ var values = [ ] ;
205+ nextProps . data . datasets . forEach ( function ( set ) {
206+ values . push ( set . data [ pointIndex ] ) ;
207+ } ) ;
208+ chart . addData ( values , nextProps . data . labels [ setIndex ] ) ;
209+ } ;
210+
211+
212+ /***/ } ,
213+ /* 3 */
214+ /***/ function ( module , exports ) {
215+
216+ module . exports = __WEBPACK_EXTERNAL_MODULE_3__ ;
217+
218+ /***/ } ,
219+ /* 4 */
220+ /***/ function ( module , exports ) {
221+
222+ module . exports = __WEBPACK_EXTERNAL_MODULE_4__ ;
223+
224+ /***/ } ,
225+ /* 5 */
226+ /***/ function ( module , exports ) {
227+
228+ module . exports = __WEBPACK_EXTERNAL_MODULE_5__ ;
229+
230+ /***/ } ,
231+ /* 6 */
232+ /***/ function ( module , exports , __webpack_require__ ) {
233+
234+ var vars = __webpack_require__ ( 2 ) ;
227235
236+ module . exports = vars . createClass ( 'Doughnut' , [ 'getSegmentsAtEvent' ] ) ;
228237
229238
239+ /***/ } ,
240+ /* 7 */
241+ /***/ function ( module , exports , __webpack_require__ ) {
242+
243+ var vars = __webpack_require__ ( 2 ) ;
244+
245+ module . exports = vars . createClass ( 'Line' , [ 'getPointsAtEvent' ] ) ;
230246
231247
232248/***/ } ,
233249/* 8 */
234250/***/ function ( module , exports , __webpack_require__ ) {
235251
236- module . exports = __WEBPACK_EXTERNAL_MODULE_8__ ;
252+ var vars = __webpack_require__ ( 2 ) ;
253+
254+ module . exports = vars . createClass ( 'Pie' , [ 'getSegmentsAtEvent' ] ) ;
255+
237256
238257/***/ } ,
239258/* 9 */
240259/***/ function ( module , exports , __webpack_require__ ) {
241260
242- module . exports = __WEBPACK_EXTERNAL_MODULE_9__ ;
261+ var vars = __webpack_require__ ( 2 ) ;
262+
263+ module . exports = vars . createClass ( 'PolarArea' , [ 'getSegmentsAtEvent' ] ) ;
264+
265+
266+ /***/ } ,
267+ /* 10 */
268+ /***/ function ( module , exports , __webpack_require__ ) {
269+
270+ var vars = __webpack_require__ ( 2 ) ;
271+
272+ module . exports = vars . createClass ( 'Radar' , [ 'getPointsAtEvent' ] ) ;
273+
243274
244275/***/ }
245276/******/ ] )
0 commit comments