/
props.js
303 lines (301 loc) · 8.47 KB
/
props.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
/*
* This file is part of the nivo project.
*
* Copyright 2016-present, Raphaël Benitte.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { BubbleDefaultProps as defaults } from '@nivo/circle-packing'
import {
themeProperty,
motionProperties,
defsProperties,
groupProperties,
} from '../../../lib/componentProperties'
const props = [
{
key: 'root',
help: 'The hierarchical data object.',
type: 'object',
required: true,
group: 'Base',
},
{
key: 'identity',
help: 'Define id accessor.',
description: `
define id accessor, if string given, will use
\`datum[value]\`, if function given, it will be
invoked for each node and will receive the node as
first argument, it must return the node value.
`,
type: 'string | Function',
required: false,
defaultValue: defaults.identity,
group: 'Base',
},
{
key: 'value',
help: 'Define value accessor.',
description: `
define value accessor, if string given, will use
\`datum[value]\`, if function given, it will be
invoked for each node and will receive the node as
first argument, it must return the node value.
`,
type: 'string | Function',
required: false,
defaultValue: 'value',
group: 'Base',
},
{
key: 'width',
enableControlForFlavors: ['api'],
help: 'Chart width.',
description: `
not required if using \`<ResponsiveBubble/>\`.
`,
type: 'number',
required: true,
controlType: 'range',
group: 'Base',
controlOptions: {
unit: 'px',
min: 100,
max: 1000,
step: 5,
},
},
{
key: 'height',
enableControlForFlavors: ['api'],
help: 'Chart height.',
description: `
not required if using \`<ResponsiveBubble/>\`.
`,
type: 'number',
required: true,
controlType: 'range',
group: 'Base',
controlOptions: {
unit: 'px',
min: 100,
max: 1000,
step: 5,
},
},
{
key: 'pixelRatio',
flavors: ['canvas'],
help: `Adjust pixel ratio, useful for HiDPI screens.`,
required: false,
defaultValue: 'Depends on device',
type: `number`,
controlType: 'range',
group: 'Base',
controlOptions: {
min: 1,
max: 2,
},
},
{
key: 'leavesOnly',
help: 'Only render leaf nodes (skip parent nodes).',
type: 'boolean',
required: false,
defaultValue: defaults.leavesOnly,
controlType: 'switch',
group: 'Base',
},
{
key: 'margin',
help: 'Chart margin.',
type: 'object',
required: false,
controlType: 'margin',
group: 'Base',
},
{
key: 'padding',
help: 'Padding between each circle.',
description: `
Padding between adjacent circles.
Please be aware that when zoomed
this value will be affected by the zooming factor
and is expressed in pixels. See the
[official d3 documentation](https://github.com/d3/d3-hierarchy#pack_padding).
`,
type: 'number',
required: false,
defaultValue: defaults.padding,
controlType: 'range',
group: 'Base',
controlOptions: {
unit: 'px',
min: 0,
max: 32,
},
},
themeProperty,
{
key: 'colors',
help: 'Defines how to compute node color.',
description: `
colors used to colorize the circles,
[see dedicated documentation](self:/guides/colors).
`,
type: 'string | Function | string[]',
required: false,
defaultValue: { scheme: 'nivo' },
controlType: 'ordinalColors',
group: 'Style',
},
{
key: 'colorBy',
type: 'string | Function',
help: 'Property used to determine node color.',
description: `
Property to use to determine node color.
If a function is provided, it will receive
the current node data and must return
a string or number which will be passed
to the color generator.
`,
required: false,
defaultValue: defaults.colorBy,
controlType: 'choices',
group: 'Style',
controlOptions: {
choices: [
{
label: 'depth',
value: 'depth',
},
{
label: 'name',
value: 'name',
},
],
},
},
{
key: 'borderWidth',
help: 'Width of circle border.',
type: 'number',
required: false,
defaultValue: defaults.borderWidth,
controlType: 'lineWidth',
group: 'Style',
},
{
key: 'borderColor',
help: 'Method to compute border color.',
description: `
how to compute border color,
[see dedicated documentation](self:/guides/colors).
`,
type: 'string | object | Function',
required: false,
defaultValue: defaults.borderColor,
controlType: 'inheritedColor',
group: 'Style',
},
...defsProperties('Style', ['svg']),
{
key: 'enableLabel',
help: 'Enable/disable labels.',
type: 'boolean',
required: false,
defaultValue: defaults.enableLabel,
controlType: 'switch',
group: 'Labels',
},
{
key: 'label',
help: 'Label accessor.',
description: `
Defines how to get label text,
can be a string (used to access current node data property)
or a function which will receive the actual node data.
`,
type: 'string | Function',
required: false,
defaultValue: defaults.label,
controlType: 'choices',
group: 'Labels',
controlOptions: {
choices: ['id', 'value', `d => \`\${d.id}: \${d.value}\``].map(choice => ({
label: choice,
value: choice,
})),
},
},
{
key: 'labelFormat',
group: 'Labels',
help: 'Labels formatting.',
description: `
How to format label,
[see d3.format() documentation](https://github.com/d3/d3-format/blob/master/README.md#format).
`,
type: 'string | Function',
},
{
key: 'labelTextColor',
help: 'Method to compute label text color.',
description: `
how to compute label text color,
[see dedicated documentation](self:/guides/colors).
`,
type: 'string | object | Function',
required: false,
defaultValue: defaults.labelTextColor,
controlType: 'inheritedColor',
group: 'Labels',
},
{
key: 'labelSkipRadius',
help: 'Skip label rendering if node radius is lower than given value, 0 to disable.',
type: 'number',
required: false,
defaultValue: defaults.labelSkipRadius,
controlType: 'range',
group: 'Labels',
controlOptions: {
unit: 'px',
min: 0,
max: 32,
},
},
{
key: 'isInteractive',
flavors: ['svg', 'html'],
help: 'Enable/disable interactivity.',
type: 'boolean',
required: false,
defaultValue: defaults.isInteractive,
controlType: 'switch',
group: 'Interactivity',
},
{
key: 'isZoomable',
flavors: ['svg', 'html'],
help: `Enable/disable zooming ('isInteractive' must also be 'true').`,
type: 'boolean',
required: false,
defaultValue: defaults.isZoomable,
controlType: 'switch',
group: 'Interactivity',
},
{
key: 'onClick',
group: 'Interactivity',
flavors: ['svg', 'html'],
help: 'onClick handler, it receives clicked node data and mouse event.',
type: 'Function',
required: false,
},
...motionProperties(['svg', 'html'], defaults),
]
export const groups = groupProperties(props)