22
33var Lib = require ( '../../lib' ) ;
44var attributes = require ( './attributes' ) ;
5- var Colorscale = require ( '../../components/colorscale' ) ;
6- var colorscaleDefaults = Colorscale . handleDefaults ;
7- var hasColorscale = Colorscale . hasColorscale ;
5+ var colorscaleDefaults = require ( '../../components/colorscale/defaults' ) ;
86
97module . exports = function supplyDefaults ( traceIn , traceOut , defaultColor , layout ) {
10- // Selection styling - use coerce to set proper defaults
118 function coerce ( attr , dflt ) {
129 return Lib . coerce ( traceIn , traceOut , attributes , attr , dflt ) ;
1310 }
@@ -17,7 +14,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
1714 var y = coerce ( 'y' ) ;
1815 var u = coerce ( 'u' ) ;
1916 var v = coerce ( 'v' ) ;
20-
17+
2118 // Optional scalar field for colorscale
2219 coerce ( 'c' ) ;
2320
@@ -40,46 +37,48 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
4037 for ( var j = 0 ; j < len ; j ++ ) traceOut . v [ j ] = 0 ;
4138 }
4239
43- // Set basic properties
44- traceOut . type = 'quiver' ;
45-
4640 // Sizing API similar to cone
4741 var sizemode = coerce ( 'sizemode' ) ;
4842 coerce ( 'sizeref' , sizemode === 'raw' ? 1 : 0.5 ) ;
4943 coerce ( 'anchor' ) ;
5044
51- // Set default values using coerce
52- coerce ( 'arrowsize' , 1 ) ;
53- // back-compat
54- coerce ( 'arrow_scale' ) ;
55- coerce ( 'hoverdistance' , 20 ) ;
45+ // Arrow styling
46+ coerce ( 'arrowsize' ) ;
47+ coerce ( 'arrow_scale' ) ; // back-compat alias
48+ coerce ( 'arrowwidth' ) ;
49+ coerce ( 'hoverdistance' ) ;
50+
51+ // Line styling - use coerce for proper validation
52+ coerce ( 'line.color' , defaultColor ) ;
53+ // If arrowwidth is set, use it as line.width default
54+ var arrowwidth = traceOut . arrowwidth ;
55+ if ( arrowwidth !== undefined ) {
56+ coerce ( 'line.width' , arrowwidth ) ;
57+ } else {
58+ coerce ( 'line.width' ) ;
59+ }
60+ coerce ( 'line.dash' ) ;
61+ coerce ( 'line.shape' ) ;
62+ coerce ( 'line.smoothing' ) ;
63+ coerce ( 'line.simplify' ) ;
5664
57- // Line styling
58- traceOut . line = {
59- color : traceIn . line && traceIn . line . color ? traceIn . line . color : defaultColor ,
60- width : ( traceIn . arrowwidth !== undefined ) ? traceIn . arrowwidth : ( traceIn . line && traceIn . line . width ? traceIn . line . width : 1 ) ,
61- dash : traceIn . line && traceIn . line . dash ? traceIn . line . dash : 'solid' ,
62- shape : traceIn . line && traceIn . line . shape ? traceIn . line . shape : 'linear' ,
63- smoothing : traceIn . line && traceIn . line . smoothing ? traceIn . line . smoothing : 1 ,
64- simplify : traceIn . line && traceIn . line . simplify !== undefined ? traceIn . line . simplify : true
65- } ;
65+ // Text
66+ coerce ( 'text' ) ;
67+ coerce ( 'textposition' ) ;
68+ Lib . coerceFont ( coerce , 'textfont' , layout . font ) ;
6669
67- // Hover and interaction - let the plots module handle hoverinfo defaults
68- // traceOut.hoverinfo will be set by Lib.coerceHoverinfo in plots.js
69- traceOut . hovertemplate = traceIn . hovertemplate ;
70+ // Hover
71+ coerce ( 'hovertemplate' ) ;
72+ coerce ( 'xhoverformat' ) ;
73+ coerce ( 'yhoverformat' ) ;
74+ coerce ( 'uhoverformat' ) ;
75+ coerce ( 'vhoverformat' ) ;
7076
7177 // Colorscale defaults (adds colorscale, showscale, colorbar, etc.)
72- // Keep colorscale enabled by default for quiver
73- traceOut . _hasColorscale = hasColorscale ( traceIn ) || true ;
78+ traceOut . _hasColorscale = true ;
7479 colorscaleDefaults ( traceIn , traceOut , layout , coerce , { prefix : '' , cLetter : 'c' } ) ;
7580
76- // Text
77- traceOut . text = traceIn . text ;
78- traceOut . textposition = traceIn . textposition || 'middle center' ;
79-
80- // Use Lib.coerceFont to set textfont properly
81- Lib . coerceFont ( coerce , 'textfont' , layout . font ) ;
82-
81+ // Selection styling
8382 coerce ( 'selected.line.color' ) ;
8483 coerce ( 'selected.line.width' ) ;
8584 coerce ( 'selected.textfont.color' ) ;
0 commit comments