1010'use strict' ;
1111
1212var Lib = require ( '../../lib' ) ;
13- var Color = require ( '../color' ) ;
1413var Axes = require ( '../../plots/cartesian/axes' ) ;
15-
14+ var handleAnnotationCommonDefaults = require ( './common_defaults' ) ;
1615var attributes = require ( './attributes' ) ;
1716
1817
@@ -29,26 +28,9 @@ module.exports = function handleAnnotationDefaults(annIn, annOut, fullLayout, op
2928
3029 if ( ! ( visible || clickToShow ) ) return annOut ;
3130
32- coerce ( 'opacity' ) ;
33- var bgColor = coerce ( 'bgcolor' ) ;
34-
35- var borderColor = coerce ( 'bordercolor' ) ,
36- borderOpacity = Color . opacity ( borderColor ) ;
37-
38- coerce ( 'borderpad' ) ;
39-
40- var borderWidth = coerce ( 'borderwidth' ) ;
41- var showArrow = coerce ( 'showarrow' ) ;
42-
43- coerce ( 'text' , showArrow ? ' ' : 'new text' ) ;
44- coerce ( 'textangle' ) ;
45- Lib . coerceFont ( coerce , 'font' , fullLayout . font ) ;
46-
47- coerce ( 'width' ) ;
48- coerce ( 'align' ) ;
31+ handleAnnotationCommonDefaults ( annIn , annOut , fullLayout , coerce ) ;
4932
50- var h = coerce ( 'height' ) ;
51- if ( h ) coerce ( 'valign' ) ;
33+ var showArrow = annOut . showarrow ;
5234
5335 // positioning
5436 var axLetters = [ 'x' , 'y' ] ,
@@ -90,14 +72,8 @@ module.exports = function handleAnnotationDefaults(annIn, annOut, fullLayout, op
9072 // if you have one coordinate you should have both
9173 Lib . noneOrAll ( annIn , annOut , [ 'x' , 'y' ] ) ;
9274
75+ // if you have one part of arrow length you should have both
9376 if ( showArrow ) {
94- coerce ( 'arrowcolor' , borderOpacity ? annOut . bordercolor : Color . defaultLine ) ;
95- coerce ( 'arrowhead' ) ;
96- coerce ( 'arrowsize' ) ;
97- coerce ( 'arrowwidth' , ( ( borderOpacity && borderWidth ) || 1 ) * 2 ) ;
98- coerce ( 'standoff' ) ;
99-
100- // if you have one part of arrow length you should have both
10177 Lib . noneOrAll ( annIn , annOut , [ 'ax' , 'ay' ] ) ;
10278 }
10379
@@ -111,25 +87,5 @@ module.exports = function handleAnnotationDefaults(annIn, annOut, fullLayout, op
11187 annOut . _yclick = ( yClick === undefined ) ? annOut . y : yClick ;
11288 }
11389
114- var hoverText = coerce ( 'hovertext' ) ;
115- var globalHoverLabel = fullLayout . hoverlabel || { } ;
116-
117- if ( hoverText ) {
118- var hoverBG = coerce ( 'hoverlabel.bgcolor' , globalHoverLabel . bgcolor ||
119- ( Color . opacity ( bgColor ) ? Color . rgb ( bgColor ) : Color . defaultLine )
120- ) ;
121-
122- var hoverBorder = coerce ( 'hoverlabel.bordercolor' , globalHoverLabel . bordercolor ||
123- Color . contrast ( hoverBG )
124- ) ;
125-
126- Lib . coerceFont ( coerce , 'hoverlabel.font' , {
127- family : globalHoverLabel . font . family ,
128- size : globalHoverLabel . font . size ,
129- color : globalHoverLabel . font . color || hoverBorder
130- } ) ;
131- }
132- coerce ( 'captureevents' , ! ! hoverText ) ;
133-
13490 return annOut ;
13591} ;
0 commit comments