-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathattributes.js
312 lines (305 loc) · 10.5 KB
/
attributes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
/**
* Copyright 2012-2016, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
var ARROWPATHS = require('./arrow_paths');
var fontAttrs = require('../../plots/font_attributes');
var cartesianConstants = require('../../plots/cartesian/constants');
var extendFlat = require('../../lib/extend').extendFlat;
module.exports = {
_isLinkedToArray: 'annotation',
visible: {
valType: 'boolean',
role: 'info',
dflt: true,
description: [
'Determines whether or not this annotation is visible.'
].join(' ')
},
text: {
valType: 'string',
role: 'info',
description: [
'Sets the text associated with this annotation.',
'Plotly uses a subset of HTML tags to do things like',
'newline (<br>), bold (<b></b>), italics (<i></i>),',
'hyperlinks (<a href=\'...\'></a>). Tags <em>, <sup>, <sub>',
'<span> are also supported.'
].join(' ')
},
textangle: {
valType: 'angle',
dflt: 0,
role: 'style',
description: [
'Sets the angle at which the `text` is drawn',
'with respect to the horizontal.'
].join(' ')
},
font: extendFlat({}, fontAttrs, {
description: 'Sets the annotation text font.'
}),
opacity: {
valType: 'number',
min: 0,
max: 1,
dflt: 1,
role: 'style',
description: 'Sets the opacity of the annotation (text + arrow).'
},
align: {
valType: 'enumerated',
values: ['left', 'center', 'right'],
dflt: 'center',
role: 'style',
description: [
'Sets the vertical alignment of the `text` with',
'respect to the set `x` and `y` position.',
'Has only an effect if `text` spans more two or more lines',
'(i.e. `text` contains one or more <br> HTML tags).'
].join(' ')
},
bgcolor: {
valType: 'color',
dflt: 'rgba(0,0,0,0)',
role: 'style',
description: 'Sets the background color of the annotation.'
},
bordercolor: {
valType: 'color',
dflt: 'rgba(0,0,0,0)',
role: 'style',
description: [
'Sets the color of the border enclosing the annotation `text`.'
].join(' ')
},
borderpad: {
valType: 'number',
min: 0,
dflt: 1,
role: 'style',
description: [
'Sets the padding (in px) between the `text`',
'and the enclosing border.'
].join(' ')
},
borderwidth: {
valType: 'number',
min: 0,
dflt: 1,
role: 'style',
description: [
'Sets the width (in px) of the border enclosing',
'the annotation `text`.'
].join(' ')
},
// arrow
showarrow: {
valType: 'boolean',
dflt: true,
role: 'style',
description: [
'Determines whether or not the annotation is drawn with an arrow.',
'If *true*, `text` is placed near the arrow\'s tail.',
'If *false*, `text` lines up with the `x` and `y` provided.'
].join(' ')
},
arrowcolor: {
valType: 'color',
role: 'style',
description: 'Sets the color of the annotation arrow.'
},
arrowhead: {
valType: 'integer',
min: 0,
max: ARROWPATHS.length,
dflt: 1,
role: 'style',
description: 'Sets the annotation arrow head style.'
},
arrowsize: {
valType: 'number',
min: 0.3,
dflt: 1,
role: 'style',
description: 'Sets the size (in px) of annotation arrow head.'
},
arrowwidth: {
valType: 'number',
min: 0.1,
role: 'style',
description: 'Sets the width (in px) of annotation arrow.'
},
ax: {
valType: 'any',
role: 'info',
description: [
'Sets the x component of the arrow tail about the arrow head.',
'If `axref` is `pixel`, a positive (negative) ',
'component corresponds to an arrow pointing',
'from right to left (left to right).',
'If `axref` is an axis, this is an absolute value on that axis,',
'like `x`, NOT a relative value.'
].join(' ')
},
ay: {
valType: 'any',
role: 'info',
description: [
'Sets the y component of the arrow tail about the arrow head.',
'If `ayref` is `pixel`, a positive (negative) ',
'component corresponds to an arrow pointing',
'from bottom to top (top to bottom).',
'If `ayref` is an axis, this is an absolute value on that axis,',
'like `y`, NOT a relative value.'
].join(' ')
},
axref: {
valType: 'enumerated',
dflt: 'pixel',
values: [
'pixel',
cartesianConstants.idRegex.x.toString()
],
role: 'info',
description: [
'Indicates in what terms the tail of the annotation (ax,ay) ',
'is specified. If `pixel`, `ax` is a relative offset in pixels ',
'from `x`. If set to an x axis id (e.g. *x* or *x2*), `ax` is ',
'specified in the same terms as that axis. This is useful ',
'for trendline annotations which should continue to indicate ',
'the correct trend when zoomed.'
].join(' ')
},
ayref: {
valType: 'enumerated',
dflt: 'pixel',
values: [
'pixel',
cartesianConstants.idRegex.y.toString()
],
role: 'info',
description: [
'Indicates in what terms the tail of the annotation (ax,ay) ',
'is specified. If `pixel`, `ay` is a relative offset in pixels ',
'from `y`. If set to a y axis id (e.g. *y* or *y2*), `ay` is ',
'specified in the same terms as that axis. This is useful ',
'for trendline annotations which should continue to indicate ',
'the correct trend when zoomed.'
].join(' ')
},
// positioning
xref: {
valType: 'enumerated',
values: [
'paper',
cartesianConstants.idRegex.x.toString()
],
role: 'info',
description: [
'Sets the annotation\'s x coordinate axis.',
'If set to an x axis id (e.g. *x* or *x2*), the `x` position',
'refers to an x coordinate',
'If set to *paper*, the `x` position refers to the distance from',
'the left side of the plotting area in normalized coordinates',
'where 0 (1) corresponds to the left (right) side.'
].join(' ')
},
x: {
valType: 'any',
role: 'info',
description: [
'Sets the annotation\'s x position.',
'If the axis `type` is *log*, then you must take the',
'log of your desired range.',
'If the axis `type` is *date*, it should be date strings,',
'like date data, though Date objects and unix milliseconds',
'will be accepted and converted to strings.',
'If the axis `type` is *category*, it should be numbers,',
'using the scale where each category is assigned a serial',
'number from zero in the order it appears.'
].join(' ')
},
xanchor: {
valType: 'enumerated',
values: ['auto', 'left', 'center', 'right'],
dflt: 'auto',
role: 'info',
description: [
'Sets the annotation\'s horizontal position anchor',
'This anchor binds the `x` position to the *left*, *center*',
'or *right* of the annotation.',
'For example, if `x` is set to 1, `xref` to *paper* and',
'`xanchor` to *right* then the right-most portion of the',
'annotation lines up with the right-most edge of the',
'plotting area.',
'If *auto*, the anchor is equivalent to *center* for',
'data-referenced annotations',
'whereas for paper-referenced, the anchor picked corresponds',
'to the closest side.'
].join(' ')
},
yref: {
valType: 'enumerated',
values: [
'paper',
cartesianConstants.idRegex.y.toString()
],
role: 'info',
description: [
'Sets the annotation\'s y coordinate axis.',
'If set to an y axis id (e.g. *y* or *y2*), the `y` position',
'refers to an y coordinate',
'If set to *paper*, the `y` position refers to the distance from',
'the bottom of the plotting area in normalized coordinates',
'where 0 (1) corresponds to the bottom (top).'
].join(' ')
},
y: {
valType: 'any',
role: 'info',
description: [
'Sets the annotation\'s y position.',
'If the axis `type` is *log*, then you must take the',
'log of your desired range.',
'If the axis `type` is *date*, it should be date strings,',
'like date data, though Date objects and unix milliseconds',
'will be accepted and converted to strings.',
'If the axis `type` is *category*, it should be numbers,',
'using the scale where each category is assigned a serial',
'number from zero in the order it appears.'
].join(' ')
},
yanchor: {
valType: 'enumerated',
values: ['auto', 'top', 'middle', 'bottom'],
dflt: 'auto',
role: 'info',
description: [
'Sets the annotation\'s vertical position anchor',
'This anchor binds the `y` position to the *top*, *middle*',
'or *bottom* of the annotation.',
'For example, if `y` is set to 1, `yref` to *paper* and',
'`yanchor` to *top* then the top-most portion of the',
'annotation lines up with the top-most edge of the',
'plotting area.',
'If *auto*, the anchor is equivalent to *middle* for',
'data-referenced annotations',
'whereas for paper-referenced, the anchor picked corresponds',
'to the closest side.'
].join(' ')
},
_deprecated: {
ref: {
valType: 'string',
role: 'info',
description: [
'Obsolete. Set `xref` and `yref` separately instead.'
].join(' ')
}
}
};