@@ -182,6 +182,70 @@ describe('groupby', function() {
182
182
. then ( done ) ;
183
183
} ) ;
184
184
185
+ it ( 'Plotly.react should work' , function ( done ) {
186
+ var data = Lib . extendDeep ( [ ] , mockData0 ) ;
187
+ data [ 0 ] . marker = { size : 20 } ;
188
+
189
+ var gd = createGraphDiv ( ) ;
190
+ var dims = [ 4 , 3 ] ;
191
+
192
+ Plotly . plot ( gd , data ) . then ( function ( ) {
193
+ assertStyle ( dims ,
194
+ [ 'rgb(255, 0, 0)' , 'rgb(0, 0, 255)' ] ,
195
+ [ 1 , 1 ]
196
+ ) ;
197
+
198
+ gd . data [ 0 ] . marker . opacity = 0.4 ;
199
+ // contrived test of relinkPrivateKeys
200
+ // we'll have to do better if we refactor it to opt-in instead of catchall
201
+ gd . _fullData [ 0 ] . marker . _boo = 'here I am' ;
202
+ return Plotly . react ( gd , gd . data , gd . layout ) ;
203
+ } ) . then ( function ( ) {
204
+ assertStyle ( dims ,
205
+ [ 'rgb(255, 0, 0)' , 'rgb(0, 0, 255)' ] ,
206
+ [ 0.4 , 0.4 ]
207
+ ) ;
208
+
209
+ expect ( gd . _fullData [ 0 ] . marker . opacity ) . toEqual ( 0.4 ) ;
210
+ expect ( gd . _fullData [ 1 ] . marker . opacity ) . toEqual ( 0.4 ) ;
211
+ expect ( gd . _fullData [ 0 ] . marker . _boo ) . toBe ( 'here I am' ) ;
212
+
213
+ gd . data [ 0 ] . marker . opacity = 1 ;
214
+ return Plotly . react ( gd , gd . data , gd . layout ) ;
215
+ } ) . then ( function ( ) {
216
+ assertStyle ( dims ,
217
+ [ 'rgb(255, 0, 0)' , 'rgb(0, 0, 255)' ] ,
218
+ [ 1 , 1 ]
219
+ ) ;
220
+
221
+ expect ( gd . _fullData [ 0 ] . marker . opacity ) . toEqual ( 1 ) ;
222
+ expect ( gd . _fullData [ 1 ] . marker . opacity ) . toEqual ( 1 ) ;
223
+
224
+ // edit just affects the first group
225
+ gd . data [ 0 ] . transforms [ 0 ] . styles [ 0 ] . value . marker . color = 'green' ;
226
+ return Plotly . react ( gd , gd . data , gd . layout ) ;
227
+ } ) . then ( function ( ) {
228
+ assertStyle ( dims ,
229
+ [ 'rgb(0, 128, 0)' , 'rgb(0, 0, 255)' ] ,
230
+ [ 1 , 1 ]
231
+ ) ;
232
+
233
+ expect ( gd . _fullData [ 0 ] . marker . opacity ) . toEqual ( 1 ) ;
234
+ expect ( gd . _fullData [ 1 ] . marker . opacity ) . toEqual ( 1 ) ;
235
+
236
+ // edit just affects the second group
237
+ gd . data [ 0 ] . transforms [ 0 ] . styles [ 1 ] . value . marker . color = 'red' ;
238
+ return Plotly . react ( gd , gd . data , gd . layout ) ;
239
+ } ) . then ( function ( ) {
240
+ assertStyle ( dims ,
241
+ [ 'rgb(0, 128, 0)' , 'rgb(255, 0, 0)' ] ,
242
+ [ 1 , 1 ]
243
+ ) ;
244
+ } )
245
+ . catch ( failTest )
246
+ . then ( done ) ;
247
+ } ) ;
248
+
185
249
it ( 'Plotly.extendTraces should work' , function ( done ) {
186
250
var data = Lib . extendDeep ( [ ] , mockData0 ) ;
187
251
0 commit comments