@@ -14,6 +14,32 @@ var cartesianConstants = require('../../plots/cartesian/constants');
14
14
var templatedArray = require ( '../../plot_api/plot_template' ) . templatedArray ;
15
15
var axisPlaceableObjs = require ( '../../constants/axis_placeable_objects' ) ;
16
16
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
+ }
17
43
18
44
module . exports = templatedArray ( 'annotation' , {
19
45
visible : {
@@ -255,25 +281,15 @@ module.exports = templatedArray('annotation', {
255
281
role : 'info' ,
256
282
editType : 'calc+arraydraw' ,
257
283
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' )
264
285
] . join ( ' ' )
265
286
} ,
266
287
ay : {
267
288
valType : 'any' ,
268
289
role : 'info' ,
269
290
editType : 'calc+arraydraw' ,
270
291
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' )
277
293
] . join ( ' ' )
278
294
} ,
279
295
axref : {
@@ -286,12 +302,10 @@ module.exports = templatedArray('annotation', {
286
302
role : 'info' ,
287
303
editType : 'calc' ,
288
304
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' )
295
309
] . join ( ' ' )
296
310
} ,
297
311
ayref : {
@@ -304,12 +318,10 @@ module.exports = templatedArray('annotation', {
304
318
role : 'info' ,
305
319
editType : 'calc' ,
306
320
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' )
313
325
] . join ( ' ' )
314
326
} ,
315
327
// positioning
0 commit comments