-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathattributes.js
324 lines (293 loc) · 9.67 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
/**
* 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 hovertemplateAttrs = require('../../plots/template_attributes').hovertemplateAttrs;
var texttemplateAttrs = require('../../plots/template_attributes').texttemplateAttrs;
var colorScaleAttrs = require('../../components/colorscale/attributes');
var domainAttrs = require('../../plots/domain').attributes;
var pieAttrs = require('../pie/attributes');
var sunburstAttrs = require('../sunburst/attributes');
var constants = require('./constants');
var extendFlat = require('../../lib/extend').extendFlat;
module.exports = {
labels: sunburstAttrs.labels,
parents: sunburstAttrs.parents,
values: sunburstAttrs.values,
branchvalues: sunburstAttrs.branchvalues,
count: sunburstAttrs.count,
level: sunburstAttrs.level,
maxdepth: sunburstAttrs.maxdepth,
tiling: {
packing: {
valType: 'enumerated',
values: [
'squarify',
'binary',
'dice',
'slice',
'slice-dice',
'dice-slice'
],
dflt: 'squarify',
role: 'info',
editType: 'plot',
description: [
'Determines d3 treemap solver.',
'For more info please refer to https://github.com/d3/d3-hierarchy#treemap-tiling'
].join(' ')
},
squarifyratio: {
valType: 'number',
role: 'info',
min: 1,
dflt: 1,
editType: 'plot',
description: [
'When using *squarify* `packing` algorithm, according to https://github.com/d3/d3-hierarchy/blob/master/README.md#squarify_ratio',
'this option specifies the desired aspect ratio of the generated rectangles.',
'The ratio must be specified as a number greater than or equal to one.',
'Note that the orientation of the generated rectangles (tall or wide)',
'is not implied by the ratio; for example, a ratio of two will attempt',
'to produce a mixture of rectangles whose width:height ratio is either 2:1 or 1:2.',
'When using *squarify*, unlike d3 which uses the Golden Ratio i.e. 1.618034,',
'Plotly applies 1 to increase squares in treemap layouts.'
].join(' ')
},
mirror: {
valType: 'flaglist',
role: 'info',
flags: [
'x',
'y'
],
dflt: '',
editType: 'plot',
description: [
'Determines if the positions obtained from solver are mirrored on each axis.'
].join(' ')
},
pad: {
valType: 'number',
role: 'style',
min: 0,
dflt: 3,
editType: 'plot',
description: [
'Sets the inner padding (in px).'
].join(' ')
},
editType: 'calc',
},
marker: extendFlat({
pad: {
top: {
valType: 'number',
role: 'style',
min: 0,
dflt: 'auto',
editType: 'plot',
description: [
'Sets the padding form the top (in px).'
].join(' ')
},
left: {
valType: 'number',
role: 'style',
min: 0,
dflt: 'auto',
editType: 'plot',
description: [
'Sets the padding form the left (in px).'
].join(' ')
},
right: {
valType: 'number',
role: 'style',
min: 0,
dflt: 'auto',
editType: 'plot',
description: [
'Sets the padding form the right (in px).'
].join(' ')
},
bottom: {
valType: 'number',
role: 'style',
min: 0,
dflt: 'auto',
editType: 'plot',
description: [
'Sets the padding form the bottom (in px).'
].join(' ')
},
editType: 'calc'
},
colors: {
valType: 'data_array',
editType: 'calc',
description: [
'Sets the color of each sector of this treemap chart.',
'If not specified, the default trace color set is used',
'to pick the sector colors.'
].join(' ')
},
opacity: {
valType: 'number',
editType: 'style',
role: 'style',
min: 0,
max: 1,
dflt: 1,
description: [
'Sets the opacity for the sectors. With colorscale',
'it is defaulted to 1; otherwise it is defaulted to 0.5'
].join(' ')
},
line: {
color: extendFlat({}, pieAttrs.marker.line.color, {
dflt: null,
description: [
'Sets the color of the line enclosing each sector.',
'Defaults to the `paper_bgcolor` value.'
].join(' ')
}),
width: extendFlat({}, pieAttrs.marker.line.width, {dflt: 1}),
editType: 'calc'
},
editType: 'calc'
},
colorScaleAttrs('marker', {
colorAttr: 'colors',
anim: false // TODO: set to anim: true?
})
),
branch: {
opacity: {
valType: 'number',
editType: 'style',
role: 'style',
min: 0,
max: 1,
description: [
'Sets the opacity of the leaves i.e. based on the hierarchy height.',
'With colorscale it is defaulted to 1; otherwise it is defaulted to 0.7'
].join(' ')
},
editType: 'plot'
},
pathbar: {
visible: {
valType: 'boolean',
dflt: true,
role: 'info',
editType: 'plot',
description: [
'Determines if the path bar is drawn.'
].join(' ')
},
position: {
valType: 'enumerated',
values: [
'top',
'bottom'
],
dflt: 'top',
role: 'info',
editType: 'plot',
description: [
'Determines on which side of the the treemap the',
'`pathbar` should be presented.'
].join(' ')
},
divider: {
valType: 'enumerated',
values: [
'>',
'<',
'|',
'/',
'\\'
],
dflt: 'auto',
role: 'style',
editType: 'plot',
description: [
'Determines which divider is used between labels.',
'With *top* `pathbar.position` it is defaulted to */*; and',
'with *bottom* `pathbar.position` it is defaulted to *\\*.'
].join(' ')
},
height: {
valType: 'number',
dflt: 'auto',
min: 12,
role: 'info',
editType: 'plot',
description: [
'Sets the height (in px). If not specified the `parbath.textfont.size` is used',
'with 3 pixles extra padding on each side.'
].join(' ')
},
textfont: extendFlat({}, pieAttrs.textfont, {
description: 'Sets the font used inside `pathbar`.'
}),
editType: 'calc'
},
text: pieAttrs.text,
textinfo: sunburstAttrs.textinfo,
// TODO: incorporate `label` and `value` in the eventData
texttemplate: texttemplateAttrs({editType: 'plot'}, {
keys: constants.eventDataKeys.concat(['label', 'value'])
}),
hovertext: pieAttrs.hovertext,
hoverinfo: sunburstAttrs.hoverinfo,
hovertemplate: hovertemplateAttrs({}, {
keys: constants.eventDataKeys
}),
textfont: pieAttrs.textfont,
insidetextfont: pieAttrs.insidetextfont,
outsidetextfont: pieAttrs.outsidetextfont,
textposition: {
valType: 'enumerated',
values: [
'top left', 'top center', 'top right',
'middle left', 'middle center', 'middle right',
'bottom left', 'bottom center', 'bottom right'
],
dflt: 'top left',
role: 'style',
editType: 'plot',
description: [
'Sets the positions of the `text` elements.'
].join(' ')
},
domain: domainAttrs({name: 'treemap', trace: true, editType: 'calc'}),
_hovered: {
marker: {
line: {
color: extendFlat({}, pieAttrs.marker.line.color, {
dflt: 'auto',
description: [
'Sets the color of the line',
'enclosing each sector when it is hovered'
].join(' ')
}),
width: extendFlat({}, pieAttrs.marker.line.width, {
dflt: 'auto',
description: [
'Sets the width (in px) of the line',
'enclosing each sector when it is hovered.'
].join(' ')
}),
editType: 'style'
},
editType: 'style'
},
editType: 'style'
}
};