1
1
( function webpackUniversalModuleDefinition ( root , factory ) {
2
2
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 ") ) ;
4
4
else if ( typeof define === 'function' && define . amd )
5
- define ( [ "Chartjs " , "react" ] , factory ) ;
5
+ define ( [ "react " , "react-dom" , "Chartjs "] , factory ) ;
6
6
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 ") ) ;
8
8
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__ ) {
11
11
return /******/ ( function ( modules ) { // webpackBootstrap
12
12
/******/ // The module cache
13
13
/******/ var installedModules = { } ;
@@ -56,20 +56,20 @@ return /******/ (function(modules) { // webpackBootstrap
56
56
57
57
module . exports = {
58
58
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
65
65
} ;
66
66
67
67
68
68
/***/ } ,
69
69
/* 1 */
70
70
/***/ function ( module , exports , __webpack_require__ ) {
71
71
72
- var vars = __webpack_require__ ( 7 ) ;
72
+ var vars = __webpack_require__ ( 2 ) ;
73
73
74
74
module . exports = vars . createClass ( 'Bar' , [ 'getBarsAtEvent' ] ) ;
75
75
@@ -78,50 +78,8 @@ return /******/ (function(modules) { // webpackBootstrap
78
78
/* 2 */
79
79
/***/ function ( module , exports , __webpack_require__ ) {
80
80
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 ) ;
125
83
126
84
module . exports = {
127
85
createClass : function ( chartType , methodNames , dataKey ) {
@@ -146,7 +104,7 @@ return /******/ (function(modules) { // webpackBootstrap
146
104
var extras = [ 'clear' , 'stop' , 'resize' , 'toBase64Image' , 'generateLegend' , 'update' , 'addData' , 'removeData' ] ;
147
105
function extra ( type ) {
148
106
classData [ type ] = function ( ) {
149
- this . state . chart [ name ] . apply ( this . state . chart , arguments ) ;
107
+ return this . state . chart [ type ] . apply ( this . state . chart , arguments ) ;
150
108
} ;
151
109
}
152
110
@@ -161,19 +119,23 @@ return /******/ (function(modules) { // webpackBootstrap
161
119
162
120
classData . componentWillReceiveProps = function ( nextProps ) {
163
121
var chart = this . state . chart ;
164
- if ( this . props . redraw ) {
122
+ if ( nextProps . redraw ) {
165
123
chart . destroy ( ) ;
166
124
this . initializeChart ( nextProps ) ;
167
125
} else {
168
126
dataKey = dataKey || dataKeys [ chart . name ] ;
169
127
updatePoints ( nextProps , chart , dataKey ) ;
128
+ if ( chart . scale ) {
129
+ chart . scale . xLabels = nextProps . data . labels ;
130
+ chart . scale . calculateXLabelRotation ( ) ;
131
+ }
170
132
chart . update ( ) ;
171
133
}
172
134
} ;
173
135
174
136
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 ) ;
177
139
var ctx = el . getContext ( "2d" ) ;
178
140
var chart = new Chart ( ctx ) [ chartType ] ( nextProps . data , nextProps . options || { } ) ;
179
141
this . state . chart = chart ;
@@ -186,9 +148,11 @@ return /******/ (function(modules) { // webpackBootstrap
186
148
187
149
// return the canvass element that contains the chart
188
150
classData . getCanvass = function ( ) {
189
- return this . refs . canvass . getDOMNode ( ) ;
151
+ return this . refs . canvass ;
190
152
} ;
191
153
154
+ classData . getCanvas = classData . getCanvass ;
155
+
192
156
var i ;
193
157
for ( i = 0 ; i < extras . length ; i ++ ) {
194
158
extra ( extras [ i ] ) ;
@@ -197,7 +161,6 @@ return /******/ (function(modules) { // webpackBootstrap
197
161
extra ( methodNames [ i ] ) ;
198
162
}
199
163
200
- var React = __webpack_require__ ( 9 ) ;
201
164
return React . createClass ( classData ) ;
202
165
}
203
166
} ;
@@ -213,33 +176,101 @@ return /******/ (function(modules) { // webpackBootstrap
213
176
214
177
if ( name === 'PolarArea' || name === 'Pie' || name === 'Doughnut' ) {
215
178
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
+ }
217
186
} ) ;
218
187
} else {
188
+ while ( chart . scale . xLabels . length > nextProps . data . labels . length ) {
189
+ chart . removeData ( ) ;
190
+ }
219
191
nextProps . data . datasets . forEach ( function ( set , setIndex ) {
220
192
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
+ }
222
198
} ) ;
223
199
} ) ;
224
200
}
225
201
} ;
226
202
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 ) ;
227
235
236
+ module . exports = vars . createClass ( 'Doughnut' , [ 'getSegmentsAtEvent' ] ) ;
228
237
229
238
239
+ /***/ } ,
240
+ /* 7 */
241
+ /***/ function ( module , exports , __webpack_require__ ) {
242
+
243
+ var vars = __webpack_require__ ( 2 ) ;
244
+
245
+ module . exports = vars . createClass ( 'Line' , [ 'getPointsAtEvent' ] ) ;
230
246
231
247
232
248
/***/ } ,
233
249
/* 8 */
234
250
/***/ function ( module , exports , __webpack_require__ ) {
235
251
236
- module . exports = __WEBPACK_EXTERNAL_MODULE_8__ ;
252
+ var vars = __webpack_require__ ( 2 ) ;
253
+
254
+ module . exports = vars . createClass ( 'Pie' , [ 'getSegmentsAtEvent' ] ) ;
255
+
237
256
238
257
/***/ } ,
239
258
/* 9 */
240
259
/***/ function ( module , exports , __webpack_require__ ) {
241
260
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
+
243
274
244
275
/***/ }
245
276
/******/ ] )
0 commit comments