@@ -14,6 +14,32 @@ var cartesianConstants = require('../../plots/cartesian/constants');
1414var templatedArray = require ( '../../plot_api/plot_template' ) . templatedArray ;
1515var axisPlaceableObjs = require ( '../../constants/axis_placeable_objects' ) ;
1616
17+ function arrowAxisRefDescription ( axis ) {
18+ return [
19+ 'In order for absolute positioning of the arrow to work, *a' + axis +
20+ 'ref* must be exactly the same as *' + axis + 'ref*, otherwise *a' + axis +
21+ 'ref* will revert to *pixel* (explained next).' ,
22+ 'For relative positioning, *a' + axis + 'ref* can be set to *pixel*,' ,
23+ 'in which case the *a' + axis + '* value is specified in pixels' ,
24+ 'relative to *' + axis + '*.' ,
25+ 'Absolute positioning is useful' ,
26+ 'for trendline annotations which should continue to indicate' ,
27+ 'the correct trend when zoomed. Relative positioning is useful' ,
28+ 'for specifying the text offset for an annotated point.'
29+ ] . join ( ' ' ) ;
30+ }
31+
32+ function arrowCoordinateDescription ( axis , lower , upper ) {
33+ return [
34+ 'Sets the' , axis , 'component of the arrow tail about the arrow head.' ,
35+ 'If `a' + axis + 'ref` is `pixel`, a positive (negative)' ,
36+ 'component corresponds to an arrow pointing' ,
37+ 'from' , upper , 'to' , lower , '(' + lower , 'to' , upper + ').' ,
38+ 'If `a' + axis + 'ref` is not `pixel` and is exactly the same as `' + axis + 'ref`,' ,
39+ 'this is an absolute value on that axis,' ,
40+ 'like `' + axis + '`, specified in the same coordinates as `' + axis + 'ref`.'
41+ ] . join ( ' ' ) ;
42+ }
1743
1844module . exports = templatedArray ( 'annotation' , {
1945 visible : {
@@ -255,25 +281,15 @@ module.exports = templatedArray('annotation', {
255281 role : 'info' ,
256282 editType : 'calc+arraydraw' ,
257283 description : [
258- 'Sets the x component of the arrow tail about the arrow head.' ,
259- 'If `axref` is `pixel`, a positive (negative) ' ,
260- 'component corresponds to an arrow pointing' ,
261- 'from right to left (left to right).' ,
262- 'If `axref` is an axis, this is an absolute value on that axis,' ,
263- 'like `x`, NOT a relative value.'
284+ arrowCoordinateDescription ( 'x' , 'left' , 'right' )
264285 ] . join ( ' ' )
265286 } ,
266287 ay : {
267288 valType : 'any' ,
268289 role : 'info' ,
269290 editType : 'calc+arraydraw' ,
270291 description : [
271- 'Sets the y component of the arrow tail about the arrow head.' ,
272- 'If `ayref` is `pixel`, a positive (negative) ' ,
273- 'component corresponds to an arrow pointing' ,
274- 'from bottom to top (top to bottom).' ,
275- 'If `ayref` is an axis, this is an absolute value on that axis,' ,
276- 'like `y`, NOT a relative value.'
292+ arrowCoordinateDescription ( 'y' , 'top' , 'bottom' )
277293 ] . join ( ' ' )
278294 } ,
279295 axref : {
@@ -286,12 +302,10 @@ module.exports = templatedArray('annotation', {
286302 role : 'info' ,
287303 editType : 'calc' ,
288304 description : [
289- 'Indicates in what terms the tail of the annotation (ax,ay) ' ,
290- 'is specified. If `pixel`, `ax` is a relative offset in pixels ' ,
291- 'from `x`. If set to an x axis id (e.g. *x* or *x2*), `ax` is ' ,
292- 'specified in the same terms as that axis. This is useful ' ,
293- 'for trendline annotations which should continue to indicate ' ,
294- 'the correct trend when zoomed.'
305+ 'Indicates in what coordinates the tail of the' ,
306+ 'annotation (ax,ay) is specified.' ,
307+ axisPlaceableObjs . axisRefDescription ( 'ax' , 'left' , 'right' ) ,
308+ arrowAxisRefDescription ( 'x' )
295309 ] . join ( ' ' )
296310 } ,
297311 ayref : {
@@ -304,12 +318,10 @@ module.exports = templatedArray('annotation', {
304318 role : 'info' ,
305319 editType : 'calc' ,
306320 description : [
307- 'Indicates in what terms the tail of the annotation (ax,ay) ' ,
308- 'is specified. If `pixel`, `ay` is a relative offset in pixels ' ,
309- 'from `y`. If set to a y axis id (e.g. *y* or *y2*), `ay` is ' ,
310- 'specified in the same terms as that axis. This is useful ' ,
311- 'for trendline annotations which should continue to indicate ' ,
312- 'the correct trend when zoomed.'
321+ 'Indicates in what coordinates the tail of the' ,
322+ 'annotation (ax,ay) is specified.' ,
323+ axisPlaceableObjs . axisRefDescription ( 'ay' , 'bottom' , 'top' ) ,
324+ arrowAxisRefDescription ( 'y' )
313325 ] . join ( ' ' )
314326 } ,
315327 // positioning
0 commit comments