@@ -6,13 +6,13 @@ var supplyLayoutDefaults = require('@src/plots/ternary/layout/defaults');
6
6
var d3 = require ( 'd3' ) ;
7
7
var createGraphDiv = require ( '../assets/create_graph_div' ) ;
8
8
var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
9
+ var fail = require ( '../assets/fail_test' ) ;
9
10
var mouseEvent = require ( '../assets/mouse_event' ) ;
10
11
var click = require ( '../assets/click' ) ;
11
12
var doubleClick = require ( '../assets/double_click' ) ;
12
13
var customMatchers = require ( '../assets/custom_matchers' ) ;
13
14
var getClientPosition = require ( '../assets/get_client_position' ) ;
14
15
15
-
16
16
describe ( 'ternary plots' , function ( ) {
17
17
'use strict' ;
18
18
@@ -244,6 +244,78 @@ describe('ternary plots', function() {
244
244
} ) ;
245
245
} ) ;
246
246
247
+ it ( 'should be able to reorder axis layers when relayout\'ing *layer*' , function ( done ) {
248
+ var gd = createGraphDiv ( ) ;
249
+ var fig = Lib . extendDeep ( { } , require ( '@mocks/ternary_simple.json' ) ) ;
250
+ var dflt = [
251
+ 'draglayer' , 'plotbg' , 'backplot' , 'grids' ,
252
+ 'frontplot' ,
253
+ 'aaxis' , 'aline' , 'baxis' , 'bline' , 'caxis' , 'cline'
254
+ ] ;
255
+
256
+ function _assert ( layers ) {
257
+ var toplevel = d3 . selectAll ( 'g.ternary > .toplevel' ) ;
258
+
259
+ expect ( toplevel . size ( ) ) . toBe ( layers . length , '# of layer' ) ;
260
+
261
+ toplevel . each ( function ( d , i ) {
262
+ var className = d3 . select ( this )
263
+ . attr ( 'class' )
264
+ . split ( 'toplevel ' ) [ 1 ] ;
265
+
266
+ expect ( className ) . toBe ( layers [ i ] , 'layer ' + i ) ;
267
+ } ) ;
268
+ }
269
+
270
+ Plotly . plot ( gd , fig ) . then ( function ( ) {
271
+ _assert ( dflt ) ;
272
+ return Plotly . relayout ( gd , 'ternary.aaxis.layer' , 'below traces' ) ;
273
+ } )
274
+ . then ( function ( ) {
275
+ _assert ( [
276
+ 'draglayer' , 'plotbg' , 'backplot' , 'grids' ,
277
+ 'aaxis' , 'aline' ,
278
+ 'frontplot' ,
279
+ 'baxis' , 'bline' , 'caxis' , 'cline'
280
+ ] ) ;
281
+ return Plotly . relayout ( gd , 'ternary.caxis.layer' , 'below traces' ) ;
282
+ } )
283
+ . then ( function ( ) {
284
+ _assert ( [
285
+ 'draglayer' , 'plotbg' , 'backplot' , 'grids' ,
286
+ 'aaxis' , 'aline' , 'caxis' , 'cline' ,
287
+ 'frontplot' ,
288
+ 'baxis' , 'bline'
289
+ ] ) ;
290
+ return Plotly . relayout ( gd , 'ternary.baxis.layer' , 'below traces' ) ;
291
+ } )
292
+ . then ( function ( ) {
293
+ _assert ( [
294
+ 'draglayer' , 'plotbg' , 'backplot' , 'grids' ,
295
+ 'aaxis' , 'aline' , 'baxis' , 'bline' , 'caxis' , 'cline' ,
296
+ 'frontplot'
297
+ ] ) ;
298
+ return Plotly . relayout ( gd , 'ternary.aaxis.layer' , null ) ;
299
+ } )
300
+ . then ( function ( ) {
301
+ _assert ( [
302
+ 'draglayer' , 'plotbg' , 'backplot' , 'grids' ,
303
+ 'baxis' , 'bline' , 'caxis' , 'cline' ,
304
+ 'frontplot' ,
305
+ 'aaxis' , 'aline'
306
+ ] ) ;
307
+ return Plotly . relayout ( gd , {
308
+ 'ternary.baxis.layer' : null ,
309
+ 'ternary.caxis.layer' : null
310
+ } ) ;
311
+ } )
312
+ . then ( function ( ) {
313
+ _assert ( dflt ) ;
314
+ } )
315
+ . catch ( fail )
316
+ . then ( done ) ;
317
+ } ) ;
318
+
247
319
function countTernarySubplot ( ) {
248
320
return d3 . selectAll ( '.ternary' ) . size ( ) ;
249
321
}
0 commit comments