@@ -4,8 +4,9 @@ var Plotly = require('@lib/index');
4
4
var Lib = require ( '@src/lib' ) ;
5
5
var d3 = require ( 'd3' ) ;
6
6
7
- // contourgl is not part of the dist plotly.js bundle initially
7
+ // heatmapgl & contourgl is not part of the dist plotly.js bundle initially
8
8
Plotly . register (
9
+ require ( '@lib/heatmapgl' ) ,
9
10
require ( '@lib/contourgl' )
10
11
) ;
11
12
@@ -208,4 +209,45 @@ describe('contourgl plots', function() {
208
209
mock . data [ 0 ] . line = { smoothing : 0 } ;
209
210
makePlot ( gd , mock , done ) ;
210
211
} ) ;
212
+
213
+ it ( 'should update properly' , function ( done ) {
214
+ var mock = plotDataElliptical ( 0 ) ;
215
+ var scene2d ;
216
+
217
+ Plotly . plot ( gd , mock . data , mock . layout ) . then ( function ( ) {
218
+ scene2d = gd . _fullLayout . _plots . xy . _scene2d ;
219
+
220
+ expect ( scene2d . traces [ mock . data [ 0 ] . uid ] . type ) . toEqual ( 'contourgl' ) ;
221
+ expect ( scene2d . xaxis . _min ) . toEqual ( [ { val : - 1 , pad : 0 } ] ) ;
222
+ expect ( scene2d . xaxis . _max ) . toEqual ( [ { val : 1 , pad : 0 } ] ) ;
223
+
224
+ return Plotly . relayout ( gd , 'xaxis.range' , [ 0 , - 10 ] ) ;
225
+ } ) . then ( function ( ) {
226
+ expect ( scene2d . xaxis . _min ) . toEqual ( [ ] ) ;
227
+ expect ( scene2d . xaxis . _max ) . toEqual ( [ ] ) ;
228
+
229
+ return Plotly . relayout ( gd , 'xaxis.autorange' , true ) ;
230
+ } ) . then ( function ( ) {
231
+ expect ( scene2d . xaxis . _min ) . toEqual ( [ { val : - 1 , pad : 0 } ] ) ;
232
+ expect ( scene2d . xaxis . _max ) . toEqual ( [ { val : 1 , pad : 0 } ] ) ;
233
+
234
+ return Plotly . restyle ( gd , 'type' , 'heatmapgl' ) ;
235
+ } ) . then ( function ( ) {
236
+ expect ( scene2d . traces [ mock . data [ 0 ] . uid ] . type ) . toEqual ( 'heatmapgl' ) ;
237
+ expect ( scene2d . xaxis . _min ) . toEqual ( [ { val : - 1 , pad : 0 } ] ) ;
238
+ expect ( scene2d . xaxis . _max ) . toEqual ( [ { val : 1 , pad : 0 } ] ) ;
239
+
240
+ return Plotly . relayout ( gd , 'xaxis.range' , [ 0 , - 10 ] ) ;
241
+ } ) . then ( function ( ) {
242
+ expect ( scene2d . xaxis . _min ) . toEqual ( [ ] ) ;
243
+ expect ( scene2d . xaxis . _max ) . toEqual ( [ ] ) ;
244
+
245
+ return Plotly . relayout ( gd , 'xaxis.autorange' , true ) ;
246
+ } ) . then ( function ( ) {
247
+ expect ( scene2d . xaxis . _min ) . toEqual ( [ { val : - 1 , pad : 0 } ] ) ;
248
+ expect ( scene2d . xaxis . _max ) . toEqual ( [ { val : 1 , pad : 0 } ] ) ;
249
+
250
+ done ( ) ;
251
+ } ) ;
252
+ } ) ;
211
253
} ) ;
0 commit comments