@@ -32,44 +32,14 @@ scatter.PTS_LINESONLY = 20;
32
32
33
33
scatter . attributes = require ( './attributes' ) ;
34
34
35
- scatter . handleXYDefaults = function ( traceIn , traceOut , coerce ) {
36
- var len ,
37
- x = coerce ( 'x' ) ,
38
- y = coerce ( 'y' ) ;
39
-
40
- if ( x ) {
41
- if ( y ) {
42
- len = Math . min ( x . length , y . length ) ;
43
- // TODO: not sure we should do this here... but I think
44
- // the way it works in calc is wrong, because it'll delete data
45
- // which could be a problem eg in streaming / editing if x and y
46
- // come in at different times
47
- // so we need to revisit calc before taking this out
48
- if ( len < x . length ) traceOut . x = x . slice ( 0 , len ) ;
49
- if ( len < y . length ) traceOut . y = y . slice ( 0 , len ) ;
50
- }
51
- else {
52
- len = x . length ;
53
- coerce ( 'y0' ) ;
54
- coerce ( 'dy' ) ;
55
- }
56
- }
57
- else {
58
- if ( ! y ) return 0 ;
59
-
60
- len = traceOut . y . length ;
61
- coerce ( 'x0' ) ;
62
- coerce ( 'dx' ) ;
63
- }
64
- return len ;
65
- } ;
35
+ var handleXYDefaults = require ( './xy_defaults' ) ;
66
36
67
37
scatter . supplyDefaults = function ( traceIn , traceOut , defaultColor , layout ) {
68
38
function coerce ( attr , dflt ) {
69
39
return Plotly . Lib . coerce ( traceIn , traceOut , scatter . attributes , attr , dflt ) ;
70
40
}
71
41
72
- var len = scatter . handleXYDefaults ( traceIn , traceOut , coerce ) ,
42
+ var len = handleXYDefaults ( traceIn , traceOut , coerce ) ,
73
43
// TODO: default mode by orphan points...
74
44
defaultMode = len < scatter . PTS_LINESONLY ? 'lines+markers' : 'lines' ;
75
45
if ( ! len ) {
@@ -246,39 +216,7 @@ scatter.isBubble = function(trace) {
246
216
Array . isArray ( trace . marker . size ) ) ;
247
217
} ;
248
218
249
- scatter . colorbar = function ( gd , cd ) {
250
- var trace = cd [ 0 ] . trace ,
251
- marker = trace . marker ,
252
- cbId = 'cb' + trace . uid ;
253
-
254
- gd . _fullLayout . _infolayer . selectAll ( '.' + cbId ) . remove ( ) ;
255
-
256
- // TODO unify Scatter.colorbar and Heatmap.colorbar
257
- // TODO make Plotly[module].colorbar support multiple colorbar per trace
258
-
259
- if ( marker === undefined || ! marker . showscale ) {
260
- Plotly . Plots . autoMargin ( gd , cbId ) ;
261
- return ;
262
- }
263
-
264
- var scl = Plotly . Colorscale . getScale ( marker . colorscale ) ,
265
- vals = marker . color ,
266
- cmin = marker . cmin ,
267
- cmax = marker . cmax ;
268
-
269
- if ( ! isNumeric ( cmin ) ) cmin = Plotly . Lib . aggNums ( Math . min , null , vals ) ;
270
- if ( ! isNumeric ( cmax ) ) cmax = Plotly . Lib . aggNums ( Math . max , null , vals ) ;
271
-
272
- var cb = cd [ 0 ] . t . cb = Plotly . Colorbar ( gd , cbId ) ;
273
-
274
- cb . fillcolor ( d3 . scale . linear ( )
275
- . domain ( scl . map ( function ( v ) { return cmin + v [ 0 ] * ( cmax - cmin ) ; } ) )
276
- . range ( scl . map ( function ( v ) { return v [ 1 ] ; } ) ) )
277
- . filllevels ( { start : cmin , end : cmax , size : ( cmax - cmin ) / 254 } )
278
- . options ( marker . colorbar ) ( ) ;
279
-
280
- Plotly . Lib . markTime ( 'done colorbar' ) ;
281
- } ;
219
+ scatter . colorbar = require ( './colorbar' ) ;
282
220
283
221
// used in the drawing step for 'scatter' and 'scattegeo' and
284
222
// in the convert step for 'scatter3d'
0 commit comments