@@ -37,6 +37,7 @@ scatter.moduleType = 'trace';
3737scatter . name = 'scatter' ;
3838scatter . categories = [ 'cartesian' , 'symbols' , 'markerColorscale' , 'errorBarsOK' , 'showLegend' ] ;
3939scatter . meta = {
40+ Scatter. supplyDefaults = require ( './defaults' ) ;
4041 description: [
4142 'The scatter trace type encompasses line charts, scatter charts, text charts, and bubble charts.' ,
4243 'The data visualized as scatter point or lines is set in `x` and `y`.' ,
@@ -52,142 +53,6 @@ scatter.PTS_LINESONLY = 20;
5253
5354scatter . attributes = require ( './attributes' ) ;
5455
55- var handleXYDefaults = require ( './xy_defaults' ) ;
56-
57- scatter . supplyDefaults = function ( traceIn , traceOut , defaultColor , layout ) {
58- function coerce ( attr , dflt ) {
59- return Lib . coerce ( traceIn , traceOut , scatter . attributes , attr , dflt ) ;
60- }
61-
62- var len = handleXYDefaults ( traceIn , traceOut , coerce ) ,
63- // TODO: default mode by orphan points...
64- defaultMode = len < scatter . PTS_LINESONLY ? 'lines+markers' : 'lines' ;
65- if ( ! len ) {
66- traceOut . visible = false ;
67- return ;
68- }
69-
70- coerce ( 'text' ) ;
71- coerce ( 'mode' , defaultMode ) ;
72-
73- if ( scatter . hasLines ( traceOut ) ) {
74- scatter . lineDefaults ( traceIn , traceOut , defaultColor , coerce ) ;
75- lineShapeDefaults ( traceIn , traceOut , coerce ) ;
76- coerce ( 'connectgaps' ) ;
77- }
78-
79- if ( scatter . hasMarkers ( traceOut ) ) {
80- scatter . markerDefaults ( traceIn , traceOut , defaultColor , layout , coerce ) ;
81- }
82-
83- if ( scatter . hasText ( traceOut ) ) {
84- scatter . textDefaults ( traceIn , traceOut , layout , coerce ) ;
85- }
86-
87- if ( scatter . hasMarkers ( traceOut ) || scatter . hasText ( traceOut ) ) {
88- coerce ( 'marker.maxdisplayed' ) ;
89- }
90-
91- coerce ( 'fill' ) ;
92- if ( traceOut . fill !== 'none' ) {
93- scatter . fillColorDefaults ( traceIn , traceOut , defaultColor , coerce ) ;
94- if ( ! scatter . hasLines ( traceOut ) ) lineShapeDefaults ( traceIn , traceOut , coerce ) ;
95- }
96-
97- ErrorBars . supplyDefaults ( traceIn , traceOut , defaultColor , { axis : 'y' } ) ;
98- ErrorBars . supplyDefaults ( traceIn , traceOut , defaultColor , { axis : 'x' , inherit : 'y' } ) ;
99- } ;
100-
101- // common to 'scatter', 'scatter3d', 'scattergeo' and 'scattergl'
102- scatter . lineDefaults = function ( traceIn , traceOut , defaultColor , coerce ) {
103- var markerColor = ( traceIn . marker || { } ) . color ;
104-
105- // don't try to inherit a color array
106- coerce ( 'line.color' , ( Array . isArray ( markerColor ) ? false : markerColor ) ||
107- defaultColor ) ;
108- coerce ( 'line.width' ) ;
109- coerce ( 'line.dash' ) ;
110- } ;
111-
112- function lineShapeDefaults ( traceIn , traceOut , coerce ) {
113- var shape = coerce ( 'line.shape' ) ;
114- if ( shape === 'spline' ) coerce ( 'line.smoothing' ) ;
115- }
116-
117- // common to 'scatter', 'scatter3d', 'scattergeo' and 'scattergl'
118- scatter . markerDefaults = function ( traceIn , traceOut , defaultColor , layout , coerce ) {
119- var isBubble = scatter . isBubble ( traceIn ) ,
120- lineColor = ( traceIn . line || { } ) . color ,
121- defaultMLC ;
122-
123- if ( lineColor ) defaultColor = lineColor ;
124-
125- coerce ( 'marker.symbol' ) ;
126- coerce ( 'marker.opacity' , isBubble ? 0.7 : 1 ) ;
127- coerce ( 'marker.size' ) ;
128-
129- coerce ( 'marker.color' , defaultColor ) ;
130- if ( Colorscale . hasColorscale ( traceIn , 'marker' ) ) {
131- Colorscale . handleDefaults (
132- traceIn , traceOut , layout , coerce , { prefix : 'marker.' , cLetter : 'c' }
133- ) ;
134- }
135-
136- // if there's a line with a different color than the marker, use
137- // that line color as the default marker line color
138- // mostly this is for transparent markers to behave nicely
139- if ( lineColor && traceOut . marker . color !== lineColor ) {
140- defaultMLC = lineColor ;
141- }
142- else if ( isBubble ) defaultMLC = Color . background ;
143- else defaultMLC = Color . defaultLine ;
144-
145- coerce ( 'marker.line.color' , defaultMLC ) ;
146- if ( Colorscale . hasColorscale ( traceIn , 'marker.line' ) ) {
147- Colorscale . handleDefaults (
148- traceIn , traceOut , layout , coerce , { prefix : 'marker.line.' , cLetter : 'c' }
149- ) ;
150- }
151-
152- coerce ( 'marker.line.width' , isBubble ? 1 : 0 ) ;
153-
154- if ( isBubble ) {
155- coerce ( 'marker.sizeref' ) ;
156- coerce ( 'marker.sizemin' ) ;
157- coerce ( 'marker.sizemode' ) ;
158- }
159- } ;
160-
161- // common to 'scatter', 'scatter3d' and 'scattergeo'
162- scatter . textDefaults = function ( traceIn , traceOut , layout , coerce ) {
163- coerce ( 'textposition' ) ;
164- Lib . coerceFont ( coerce , 'textfont' , layout . font ) ;
165- } ;
166-
167- // common to 'scatter' and 'scattergl'
168- scatter . fillColorDefaults = function ( traceIn , traceOut , defaultColor , coerce ) {
169- var inheritColorFromMarker = false ;
170-
171- if ( traceOut . marker ) {
172- // don't try to inherit a color array
173- var markerColor = traceOut . marker . color ,
174- markerLineColor = ( traceOut . marker . line || { } ) . color ;
175-
176- if ( markerColor && ! Array . isArray ( markerColor ) ) {
177- inheritColorFromMarker = markerColor ;
178- }
179- else if ( markerLineColor && ! Array . isArray ( markerLineColor ) ) {
180- inheritColorFromMarker = markerLineColor ;
181- }
182- }
183-
184- coerce ( 'fillcolor' , Color . addOpacity (
185- ( traceOut . line || { } ) . color ||
186- inheritColorFromMarker ||
187- defaultColor , 0.5
188- ) ) ;
189- } ;
190-
19156scatter . cleanData = function ( fullData ) {
19257 var i ,
19358 tracei ,
0 commit comments