9
9
10
10
'use strict' ;
11
11
12
- var Plotly = require ( '../../plotly' ) ;
13
12
var d3 = require ( 'd3' ) ;
14
13
var isNumeric = require ( 'fast-isnumeric' ) ;
15
14
15
+ var Plots = require ( '../../plots/plots' ) ;
16
+ var Color = require ( '../color' ) ;
17
+ var Colorscale = require ( '../colorscale' ) ;
18
+ var Lib = require ( '../../lib' ) ;
19
+ var svgTextUtils = require ( '../../lib/svg_text_utils' ) ;
20
+
16
21
var xmlnsNamespaces = require ( '../../constants/xmlns_namespaces' ) ;
17
22
var subTypes = require ( '../../traces/scatter/subtypes' ) ;
18
23
var makeBubbleSizeFn = require ( '../../traces/scatter/make_bubble_size_func' ) ;
@@ -32,7 +37,7 @@ drawing.font = function(s, family, size, color) {
32
37
}
33
38
if ( family ) s . style ( 'font-family' , family ) ;
34
39
if ( size + 1 ) s . style ( 'font-size' , size + 'px' ) ;
35
- if ( color ) s . call ( Plotly . Color . fill , color ) ;
40
+ if ( color ) s . call ( Color . fill , color ) ;
36
41
} ;
37
42
38
43
drawing . setPosition = function ( s , x , y ) { s . attr ( 'x' , x ) . attr ( 'y' , y ) ; } ;
@@ -83,7 +88,7 @@ drawing.lineGroupStyle = function(s, lw, lc, ld) {
83
88
dash = ld || line . dash || '' ;
84
89
85
90
d3 . select ( this )
86
- . call ( Plotly . Color . stroke , lc || line . color )
91
+ . call ( Color . stroke , lc || line . color )
87
92
. call ( drawing . dashLine , dash , lw1 ) ;
88
93
} ) ;
89
94
} ;
@@ -114,7 +119,7 @@ drawing.fillGroupStyle = function(s) {
114
119
. each ( function ( d ) {
115
120
var shape = d3 . select ( this ) ;
116
121
try {
117
- shape . call ( Plotly . Color . fill , d [ 0 ] . trace . fillcolor ) ;
122
+ shape . call ( Color . fill , d [ 0 ] . trace . fillcolor ) ;
118
123
}
119
124
catch ( e ) {
120
125
console . log ( e , s ) ;
@@ -178,7 +183,7 @@ drawing.pointStyle = function(s, trace) {
178
183
179
184
// only scatter & box plots get marker path and opacity
180
185
// bars, histograms don't
181
- if ( Plotly . Plots . traceIs ( trace , 'symbols' ) ) {
186
+ if ( Plots . traceIs ( trace , 'symbols' ) ) {
182
187
var sizeFn = makeBubbleSizeFn ( trace ) ;
183
188
184
189
s . attr ( 'd' , function ( d ) {
@@ -230,29 +235,29 @@ drawing.pointStyle = function(s, trace) {
230
235
231
236
if ( 'mlc' in d ) lineColor = d . mlcc = lineScale ( d . mlc ) ;
232
237
// weird case: array wasn't long enough to apply to every point
233
- else if ( Array . isArray ( markerLine . color ) ) lineColor = Plotly . Color . defaultLine ;
238
+ else if ( Array . isArray ( markerLine . color ) ) lineColor = Color . defaultLine ;
234
239
else lineColor = markerLine . color ;
235
240
236
241
if ( 'mc' in d ) fillColor = d . mcc = markerScale ( d . mc ) ;
237
- else if ( Array . isArray ( marker . color ) ) fillColor = Plotly . Color . defaultLine ;
242
+ else if ( Array . isArray ( marker . color ) ) fillColor = Color . defaultLine ;
238
243
else fillColor = marker . color || 'rgba(0,0,0,0)' ;
239
244
}
240
245
241
246
var p = d3 . select ( this ) ;
242
247
if ( d . om ) {
243
248
// open markers can't have zero linewidth, default to 1px,
244
249
// and use fill color as stroke color
245
- p . call ( Plotly . Color . stroke , fillColor )
250
+ p . call ( Color . stroke , fillColor )
246
251
. style ( {
247
252
'stroke-width' : ( lineWidth || 1 ) + 'px' ,
248
253
fill : 'none'
249
254
} ) ;
250
255
}
251
256
else {
252
257
p . style ( 'stroke-width' , lineWidth + 'px' )
253
- . call ( Plotly . Color . fill , fillColor ) ;
258
+ . call ( Color . fill , fillColor ) ;
254
259
if ( lineWidth ) {
255
- p . call ( Plotly . Color . stroke , lineColor ) ;
260
+ p . call ( Color . stroke , lineColor ) ;
256
261
}
257
262
}
258
263
} ) ;
@@ -262,11 +267,11 @@ drawing.pointStyle = function(s, trace) {
262
267
// have a colorscale for it (ie mscl, mcmin, mcmax) - if we do, translate
263
268
// all numeric color values according to that scale
264
269
drawing . tryColorscale = function ( cont , contIn , prefix ) {
265
- var colorArray = Plotly . Lib . nestedProperty ( cont , prefix + 'color' ) . get ( ) ,
266
- scl = Plotly . Lib . nestedProperty ( cont , prefix + 'colorscale' ) . get ( ) ,
267
- auto = Plotly . Lib . nestedProperty ( cont , prefix + 'cauto' ) . get ( ) ,
268
- minProp = Plotly . Lib . nestedProperty ( cont , prefix + 'cmin' ) ,
269
- maxProp = Plotly . Lib . nestedProperty ( cont , prefix + 'cmax' ) ,
270
+ var colorArray = Lib . nestedProperty ( cont , prefix + 'color' ) . get ( ) ,
271
+ scl = Lib . nestedProperty ( cont , prefix + 'colorscale' ) . get ( ) ,
272
+ auto = Lib . nestedProperty ( cont , prefix + 'cauto' ) . get ( ) ,
273
+ minProp = Lib . nestedProperty ( cont , prefix + 'cmin' ) ,
274
+ maxProp = Lib . nestedProperty ( cont , prefix + 'cmax' ) ,
270
275
min = minProp . get ( ) ,
271
276
max = maxProp . get ( ) ;
272
277
@@ -287,12 +292,12 @@ drawing.tryColorscale = function(cont, contIn, prefix) {
287
292
}
288
293
minProp . set ( min ) ;
289
294
maxProp . set ( max ) ;
290
- Plotly . Lib . nestedProperty ( contIn , prefix + 'cmin' ) . set ( min ) ;
291
- Plotly . Lib . nestedProperty ( contIn , prefix + 'cmax' ) . set ( max ) ;
295
+ Lib . nestedProperty ( contIn , prefix + 'cmin' ) . set ( min ) ;
296
+ Lib . nestedProperty ( contIn , prefix + 'cmax' ) . set ( max ) ;
292
297
}
293
- return Plotly . Colorscale . makeScaleFunction ( scl , min , max ) ;
298
+ return Colorscale . makeScaleFunction ( scl , min , max ) ;
294
299
}
295
- else return Plotly . Lib . identity ;
300
+ else return Lib . identity ;
296
301
} ;
297
302
298
303
// draw text at points
@@ -328,7 +333,7 @@ drawing.textPointStyle = function(s, trace) {
328
333
d . tc || trace . textfont . color )
329
334
. attr ( 'text-anchor' , h )
330
335
. text ( text )
331
- . call ( Plotly . util . convertToTspans ) ;
336
+ . call ( svgTextUtils . convertToTspans ) ;
332
337
var pgroup = d3 . select ( this . parentNode ) ,
333
338
tspans = p . selectAll ( 'tspan.line' ) ,
334
339
numLines = ( ( tspans [ 0 ] . length || 1 ) - 1 ) * LINEEXPAND + 1 ,
@@ -491,7 +496,7 @@ drawing.bBox = function(node) {
491
496
// remeasure the same thing many times
492
497
var saveNum = node . attributes [ 'data-bb' ] ;
493
498
if ( saveNum && saveNum . value ) {
494
- return Plotly . Lib . extendFlat ( { } , savedBBoxes [ saveNum . value ] ) ;
499
+ return Lib . extendFlat ( { } , savedBBoxes [ saveNum . value ] ) ;
495
500
}
496
501
497
502
var test3 = d3 . select ( '#js-plotly-tester' ) ,
@@ -534,7 +539,7 @@ drawing.bBox = function(node) {
534
539
node . setAttribute ( 'data-bb' , savedBBoxes . length ) ;
535
540
savedBBoxes . push ( bb ) ;
536
541
537
- return Plotly . Lib . extendFlat ( { } , bb ) ;
542
+ return Lib . extendFlat ( { } , bb ) ;
538
543
} ;
539
544
540
545
/*
0 commit comments