-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathattributes.js
332 lines (314 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
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
/**
* Copyright 2012-2019, 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 plotAttrs = require('../../plots/attributes');
var domainAttrs = require('../../plots/domain').attributes;
var fontAttrs = require('../../plots/font_attributes');
var colorAttrs = require('../../components/color/attributes');
var hovertemplateAttrs = require('../../components/fx/hovertemplate_attributes');
var texttemplateAttrs = require('../../components/fx/texttemplate_attributes');
var extendFlat = require('../../lib/extend').extendFlat;
var textFontAttrs = fontAttrs({
editType: 'plot',
arrayOk: true,
colorEditType: 'plot',
description: 'Sets the font used for `textinfo`.'
});
module.exports = {
labels: {
valType: 'data_array',
editType: 'calc',
description: [
'Sets the sector labels.',
'If `labels` entries are duplicated, we sum associated `values`',
'or simply count occurrences if `values` is not provided.',
'For other array attributes (including color) we use the first',
'non-empty entry among all occurrences of the label.'
].join(' ')
},
// equivalent of x0 and dx, if label is missing
label0: {
valType: 'number',
role: 'info',
dflt: 0,
editType: 'calc',
description: [
'Alternate to `labels`.',
'Builds a numeric set of labels.',
'Use with `dlabel`',
'where `label0` is the starting label and `dlabel` the step.'
].join(' ')
},
dlabel: {
valType: 'number',
role: 'info',
dflt: 1,
editType: 'calc',
description: 'Sets the label step. See `label0` for more info.'
},
values: {
valType: 'data_array',
editType: 'calc',
description: [
'Sets the values of the sectors.',
'If omitted, we count occurrences of each label.'
].join(' ')
},
marker: {
colors: {
valType: 'data_array', // TODO 'color_array' ?
editType: 'calc',
description: [
'Sets the color of each sector.',
'If not specified, the default trace color set is used',
'to pick the sector colors.'
].join(' ')
},
line: {
color: {
valType: 'color',
role: 'style',
dflt: colorAttrs.defaultLine,
arrayOk: true,
editType: 'style',
description: [
'Sets the color of the line enclosing each sector.'
].join(' ')
},
width: {
valType: 'number',
role: 'style',
min: 0,
dflt: 0,
arrayOk: true,
editType: 'style',
description: [
'Sets the width (in px) of the line enclosing each sector.'
].join(' ')
},
editType: 'calc'
},
editType: 'calc'
},
text: {
valType: 'data_array',
editType: 'calc',
description: [
'Sets text elements associated with each sector.',
'If trace `textinfo` contains a *text* flag, these elements will be seen',
'on the chart.',
'If trace `hoverinfo` contains a *text* flag and *hovertext* is not set,',
'these elements will be seen in the hover labels.'
].join(' ')
},
hovertext: {
valType: 'string',
role: 'info',
dflt: '',
arrayOk: true,
editType: 'style',
description: [
'Sets hover text elements associated with each sector.',
'If a single string, the same string appears for',
'all data points.',
'If an array of string, the items are mapped in order of',
'this trace\'s sectors.',
'To be seen, trace `hoverinfo` must contain a *text* flag.'
].join(' ')
},
// 'see eg:'
// 'https://www.e-education.psu.edu/natureofgeoinfo/sites/www.e-education.psu.edu.natureofgeoinfo/files/image/hisp_pies.gif',
// '(this example involves a map too - may someday be a whole trace type',
// 'of its own. but the point is the size of the whole pie is important.)'
scalegroup: {
valType: 'string',
role: 'info',
dflt: '',
editType: 'calc',
description: [
'If there are multiple pie charts that should be sized according to',
'their totals, link them by providing a non-empty group id here',
'shared by every trace in the same group.'
].join(' ')
},
// labels (legend is handled by plots.attributes.showlegend and layout.hiddenlabels)
textinfo: {
valType: 'flaglist',
role: 'info',
flags: ['label', 'text', 'value', 'percent'],
extras: ['none'],
editType: 'calc',
description: [
'Determines which trace information appear on the graph.'
].join(' ')
},
hoverinfo: extendFlat({}, plotAttrs.hoverinfo, {
flags: ['label', 'text', 'value', 'percent', 'name']
}),
hovertemplate: hovertemplateAttrs({}, {
keys: ['label', 'color', 'value', 'percent', 'text']
}),
texttemplate: texttemplateAttrs({editType: 'plot'}, {
keys: ['label', 'color', 'value', 'percent', 'text']
}),
textposition: {
valType: 'enumerated',
role: 'info',
values: ['inside', 'outside', 'auto', 'none'],
dflt: 'auto',
arrayOk: true,
editType: 'plot',
description: [
'Specifies the location of the `textinfo`.'
].join(' ')
},
textfont: extendFlat({}, textFontAttrs, {
description: 'Sets the font used for `textinfo`.'
}),
insidetextfont: extendFlat({}, textFontAttrs, {
description: 'Sets the font used for `textinfo` lying inside the sector.'
}),
outsidetextfont: extendFlat({}, textFontAttrs, {
description: 'Sets the font used for `textinfo` lying outside the sector.'
}),
title: {
text: {
valType: 'string',
dflt: '',
role: 'info',
editType: 'plot',
description: [
'Sets the title of the chart.',
'If it is empty, no title is displayed.',
'Note that before the existence of `title.text`, the title\'s',
'contents used to be defined as the `title` attribute itself.',
'This behavior has been deprecated.'
].join(' ')
},
font: extendFlat({}, textFontAttrs, {
description: [
'Sets the font used for `title`.',
'Note that the title\'s font used to be set',
'by the now deprecated `titlefont` attribute.'
].join(' ')
}),
position: {
valType: 'enumerated',
values: [
'top left', 'top center', 'top right',
'middle center',
'bottom left', 'bottom center', 'bottom right'
],
role: 'info',
editType: 'plot',
description: [
'Specifies the location of the `title`.',
'Note that the title\'s position used to be set',
'by the now deprecated `titleposition` attribute.'
].join(' ')
},
editType: 'plot'
},
// position and shape
domain: domainAttrs({name: 'pie', trace: true, editType: 'calc'}),
hole: {
valType: 'number',
role: 'style',
min: 0,
max: 1,
dflt: 0,
editType: 'calc',
description: [
'Sets the fraction of the radius to cut out of the pie.',
'Use this to make a donut chart.'
].join(' ')
},
// ordering and direction
sort: {
valType: 'boolean',
role: 'style',
dflt: true,
editType: 'calc',
description: [
'Determines whether or not the sectors are reordered',
'from largest to smallest.'
].join(' ')
},
direction: {
/**
* there are two common conventions, both of which place the first
* (largest, if sorted) slice with its left edge at 12 o'clock but
* succeeding slices follow either cw or ccw from there.
*
* see http://visage.co/data-visualization-101-pie-charts/
*/
valType: 'enumerated',
values: ['clockwise', 'counterclockwise'],
role: 'style',
dflt: 'counterclockwise',
editType: 'calc',
description: [
'Specifies the direction at which succeeding sectors follow',
'one another.'
].join(' ')
},
rotation: {
valType: 'number',
role: 'style',
min: -360,
max: 360,
dflt: 0,
editType: 'calc',
description: [
'Instead of the first slice starting at 12 o\'clock,',
'rotate to some other angle.'
].join(' ')
},
pull: {
valType: 'number',
role: 'style',
min: 0,
max: 1,
dflt: 0,
arrayOk: true,
editType: 'calc',
description: [
'Sets the fraction of larger radius to pull the sectors',
'out from the center. This can be a constant',
'to pull all slices apart from each other equally',
'or an array to highlight one or more slices.'
].join(' ')
},
_deprecated: {
title: {
valType: 'string',
dflt: '',
role: 'info',
editType: 'calc',
description: [
'Deprecated in favor of `title.text`.',
'Note that value of `title` is no longer a simple',
'*string* but a set of sub-attributes.'
].join(' ')
},
titlefont: extendFlat({}, textFontAttrs, {
description: 'Deprecated in favor of `title.font`.'
}),
titleposition: {
valType: 'enumerated',
values: [
'top left', 'top center', 'top right',
'middle center',
'bottom left', 'bottom center', 'bottom right'
],
role: 'info',
editType: 'calc',
description: 'Deprecated in favor of `title.position`.'
}
}
};