File tree 2 files changed +26
-15
lines changed
2 files changed +26
-15
lines changed Original file line number Diff line number Diff line change 8
8
9
9
'use strict' ;
10
10
11
- function sortBasePlotModules ( a , b ) {
12
- var nameA = a . name ;
13
- var nameB = b . name ;
14
-
15
- // always plot splom before cartesian (i.e. scattergl traces)
16
- if ( nameB === 'splom' && nameA === 'cartesian' ) {
17
- return 1 ;
18
- }
11
+ // always plot splom before cartesian (i.e. scattergl traces)
12
+ function sortModules ( a , b ) {
13
+ if ( a === 'splom' ) return - 1 ;
14
+ if ( b === 'splom' ) return 1 ;
19
15
return 0 ;
20
16
}
21
17
22
- function sortModules ( a , b ) {
23
- // always plot splom before scattergl traces
24
- if ( b === 'splom' && a === 'scattergl' ) {
25
- return 1 ;
26
- }
27
- return 0 ;
18
+ function sortBasePlotModules ( a , b ) {
19
+ return sortModules ( a . name , b . name ) ;
28
20
}
29
21
30
22
module . exports = {
Original file line number Diff line number Diff line change @@ -13,7 +13,6 @@ describe('Test Plots', function() {
13
13
'use strict' ;
14
14
15
15
describe ( 'Plots.supplyDefaults' , function ( ) {
16
-
17
16
it ( 'should not throw an error when gd is a plain object' , function ( ) {
18
17
var height = 100 ,
19
18
gd = {
@@ -154,6 +153,26 @@ describe('Test Plots', function() {
154
153
155
154
testSanitizeMarginsHasBeenCalledOnlyOnce ( gd ) ;
156
155
} ) ;
156
+
157
+ it ( 'should sort base plot modules on fullLayout object' , function ( ) {
158
+ var gd = Lib . extendDeep ( { } , require ( '@mocks/plot_types.json' ) ) ;
159
+ gd . data . unshift ( { type : 'scattergl' } ) ;
160
+ gd . data . push ( { type : 'splom' } ) ;
161
+
162
+ supplyAllDefaults ( gd ) ;
163
+ var names = gd . _fullLayout . _basePlotModules . map ( function ( m ) {
164
+ return m . name ;
165
+ } ) ;
166
+
167
+ expect ( names ) . toEqual ( [
168
+ 'splom' ,
169
+ 'cartesian' ,
170
+ 'gl3d' ,
171
+ 'geo' ,
172
+ 'pie' ,
173
+ 'ternary'
174
+ ] ) ;
175
+ } ) ;
157
176
} ) ;
158
177
159
178
describe ( 'Plots.supplyLayoutGlobalDefaults should' , function ( ) {
You can’t perform that action at this time.
0 commit comments