/
props.js
360 lines (357 loc) · 9.66 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
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
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
/*
* 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 { FunnelDefaultProps as defaults } from '@nivo/funnel'
import { themeProperty, groupProperties, motionProperties } from '../../../lib/componentProperties'
const props = [
{
key: 'data',
type: 'Array<Datum>',
group: 'Base',
help: 'Chart data.',
description: `
Chart data, which must conform to this structure:
\`\`\`
Array<{
id: string | number
label: string
value: number
}>
\`\`\`
`,
required: true,
},
{
key: 'margin',
group: 'Base',
type: 'object',
help: 'Chart margin.',
controlType: 'margin',
},
{
key: 'direction',
help: `Direction of the chart.`,
type: 'string',
required: false,
defaultValue: defaults.direction,
controlType: 'radio',
group: 'Base',
controlOptions: {
choices: [
{ label: 'horizontal', value: 'horizontal' },
{ label: 'vertical', value: 'vertical' },
],
},
},
{
key: 'interpolation',
group: 'Base',
type: 'string',
help: `Part shape interpolation.`,
required: false,
defaultValue: defaults.interpolation,
controlType: 'radio',
controlOptions: {
choices: [
{ label: 'smooth', value: 'smooth' },
{ label: 'linear', value: 'linear' },
],
},
},
{
key: 'spacing',
help: 'Spacing between parts',
type: 'number',
required: false,
defaultValue: defaults.spacing,
controlType: 'range',
group: 'Base',
controlOptions: {
min: 0,
max: 30,
unit: 'px',
},
},
{
key: 'shapeBlending',
help: 'Blend shapes.',
type: 'number',
required: false,
defaultValue: defaults.shapeBlending,
controlType: 'range',
group: 'Base',
controlOptions: {
min: 0,
max: 1,
step: 0.01,
},
},
{
key: 'valueFormat',
help: `
Value format supporting d3-format notation, this formatted value
will then be used for labels and tooltips.
`,
type: 'string | Function',
required: false,
controlType: 'valueFormat',
group: 'Base',
},
themeProperty,
{
key: 'colors',
help: 'Defines how to compute parts color.',
type: 'string | Function | string[]',
required: false,
defaultValue: defaults.colors,
controlType: 'ordinalColors',
group: 'Style',
},
{
key: 'fillOpacity',
help: 'Part background opacity.',
required: false,
defaultValue: defaults.fillOpacity,
type: 'number',
controlType: 'opacity',
group: 'Style',
},
{
key: 'borderWidth',
help: 'Width of part 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',
},
{
key: 'borderOpacity',
help: 'Part border opacity.',
required: false,
defaultValue: defaults.borderOpacity,
type: 'number',
controlType: 'opacity',
group: 'Style',
},
{
key: 'enableLabel',
help: `
Enable/disable labels. Use styles from
theme.labels.text.
`,
type: 'boolean',
required: false,
defaultValue: defaults.enableLabel,
controlType: 'switch',
group: 'Labels',
},
{
key: 'labelColor',
help: 'Method to compute label color.',
description: `
how to compute label color,
[see dedicated documentation](self:/guides/colors).
`,
type: 'string | object | Function',
required: false,
defaultValue: defaults.labelColor,
controlType: 'inheritedColor',
group: 'Labels',
},
{
key: 'enableBeforeSeparators',
help: `
Enable/disable before separators.
Separators inherit styles from theme.grid.line.
`,
type: 'boolean',
required: false,
defaultValue: defaults.enableBeforeSeparators,
controlType: 'switch',
group: 'Separators',
},
{
key: 'beforeSeparatorLength',
help: `
Length of the before separator lines. You should add margin
for them to be visible if the value is greater than 0.
`,
required: false,
defaultValue: defaults.beforeSeparatorLength,
type: 'number',
controlType: 'range',
group: 'Separators',
controlOptions: {
unit: 'px',
min: 0,
max: 100,
},
},
{
key: 'beforeSeparatorOffset',
help: `
Offset from the parts for the before separator lines.
You should add margin for them to be visible
if the value is greater than 0.
`,
required: false,
defaultValue: defaults.beforeSeparatorOffset,
type: 'number',
controlType: 'range',
group: 'Separators',
controlOptions: {
unit: 'px',
min: 0,
max: 100,
},
},
{
key: 'enableAfterSeparators',
help: `
Enable/disable after separators.
Separators inherit styles from theme.grid.line.
`,
type: 'boolean',
required: false,
defaultValue: defaults.enableAfterSeparators,
controlType: 'switch',
group: 'Separators',
},
{
key: 'afterSeparatorLength',
help: `
Length of the after separator lines. You should add margin
for them to be visible if the value is greater than 0.
`,
required: false,
defaultValue: defaults.afterSeparatorLength,
type: 'number',
controlType: 'range',
group: 'Separators',
controlOptions: {
unit: 'px',
min: 0,
max: 100,
},
},
{
key: 'afterSeparatorOffset',
help: `
Offset from the parts for the after separator lines.
You should add margin for them to be visible
if the value is greater than 0.
`,
required: false,
defaultValue: defaults.afterSeparatorOffset,
type: 'number',
controlType: 'range',
group: 'Separators',
controlOptions: {
unit: 'px',
min: 0,
max: 100,
},
},
{
key: 'layers',
group: 'Customization',
help: 'Defines the order of layers and add custom layers.',
description: `
You can also use this to insert extra layers
to the chart, the extra layer must be a function.
The layer function which will receive the chart's
context & computed data and must return a valid SVG element.
`,
required: false,
type: 'Array<string | Function>',
defaultValue: defaults.layers,
},
{
key: 'isInteractive',
group: 'Interactivity',
type: 'boolean',
help: 'Enable/disable interactivity.',
required: false,
defaultValue: defaults.isInteractive,
controlType: 'switch',
},
{
key: 'currentPartSizeExtension',
help: `
Expand part size by this amount of pixels on each side
when it's active
`,
required: false,
defaultValue: defaults.currentPartSizeExtension,
type: 'number',
controlType: 'range',
group: 'Interactivity',
controlOptions: {
unit: 'px',
min: 0,
max: 100,
},
},
{
key: 'currentBorderWidth',
help: `Override default border width when a part is active.`,
required: false,
type: 'number',
controlType: 'range',
group: 'Interactivity',
controlOptions: {
unit: 'px',
min: 0,
max: 100,
},
},
{
key: 'onMouseEnter',
group: 'Interactivity',
help: 'onMouseEnter handler.',
type: '(part, event) => void',
required: false,
},
{
key: 'onMouseMove',
group: 'Interactivity',
help: 'onMouseMove handler.',
type: '(part, event) => void',
required: false,
},
{
key: 'onMouseLeave',
group: 'Interactivity',
help: 'onMouseLeave handler.',
type: '(part, event) => void',
required: false,
},
{
key: 'onClick',
group: 'Interactivity',
help: 'onClick handler.',
type: '(part, event) => void',
required: false,
},
...motionProperties(['svg'], defaults, 'react-spring'),
]
export const groups = groupProperties(props)