-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
ChartProps.ts
361 lines (353 loc) · 9.45 KB
/
ChartProps.ts
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
361
import { onClick, onMouseDown, onMouseEnter, onMouseLeave, onMouseMove, onMouseUp } from './EventHandlers';
import { StorybookArg, StorybookArgs } from '../../../StorybookArgs';
export const data: StorybookArg = {
description: 'The source data, in which each element is an object.',
table: {
type: {
summary: 'Array',
},
category: 'General',
},
};
export const ChartSizeProps: StorybookArgs = {
height: {
description: 'The height of chart container.',
table: {
type: {
summary: 'number',
},
category: 'General',
},
},
width: {
description: 'The width of chart container.',
table: {
type: {
summary: 'number',
},
category: 'General',
},
},
};
export const margin = {
description: 'The sizes of whitespace around the container.',
table: {
type: {
summary: 'Object',
},
defaultValue: { top: 0, right: 0, bottom: 0, left: 0 },
category: 'General',
},
};
export const dataKey = {
description: 'The key or getter of a group of data which should be unique in a chart.',
table: {
type: {
summary: 'string | number | Function',
},
category: 'General',
},
};
// These props are shared between the following charts:
// - AreaChart
// - BarChart
// - ComposedChart
// - LineChart
// - PieChart
// - RadarChart
// - RadialBarChart
// - ScatterChart
// - FunnelChart
export const CategoricalChartProps: StorybookArgs = {
...ChartSizeProps,
dataKey: {
description: `Can be used to mirror dataKey used on children components, using it as this level will force
the chart to animate between two states even though the data array stays the same. Useful to animate when
toggling between multiple dataKey.`,
table: {
type: {
summary: 'string | number | function | undefined',
},
category: 'General',
},
},
data,
margin,
accessibilityLayer: {
description: 'Turn on accessibility support for keyboard-only and screen reader users.',
table: {
type: {
summary: 'boolean',
},
defaultValue: false,
category: 'General',
},
},
role: {
description: 'The ARIA role for the chart, which provides semantic information for screen reader users.',
table: {
type: {
summary: 'String | undefined',
},
defaultValue: undefined,
category: 'General',
},
},
tabIndex: {
description: 'If and where the chart should appear in the tab order',
table: {
type: {
summary: 'number | undefined',
},
defaultValue: undefined,
category: 'General',
},
},
barCategoryGap: {
description: 'The gap between two bar categories, which can be a percent value or a fixed value.',
table: {
type: {
summary: 'Percentage | number',
},
defaultValue: '10%',
category: 'Bar',
},
},
style: {
description: 'The style of chart.',
table: {
type: {
summary: 'Object',
},
category: 'General',
},
},
desc: {
description: 'The description of chart.',
table: {
type: {
summary: 'String',
},
category: 'General',
},
},
barGap: {
description: 'The gap between two bars in the same category.',
table: {
type: {
summary: 'number',
},
defaultValue: 4,
category: 'Bar',
},
},
barSize: {
description: `The width or height of each bar. If the barSize is not specified, the size of the bar
will be calculated by the barCategoryGap, barGap and the quantity of bar groups.`,
table: {
type: {
summary: 'number | Percentage',
},
category: 'Bar',
},
},
baseValue: {
description: 'The base value of area.',
table: {
type: {
summary: "number | 'dataMin' | 'dataMax' | 'auto'",
},
defaultValue: 'auto',
category: 'Area',
},
},
className: {
table: {
category: 'Internal',
},
},
compact: {
description: 'If true set, the chart will be rendered in compact mode.',
table: {
type: {
summary: 'boolean | undefined',
},
defaultValue: undefined,
category: 'General',
},
},
stepRatioControl: {
description: `This parameter controls the domain range for the y-axis and the step increments within that domain.
A lower value for this parameter moves the maximum y-axis value closer to the highest data point in the dataset.
For example, with the dataset [0, 400, 800, 1200, 1600], a stepRatioControl value of 0.05 would set the y-axis domain to [0, 2000].
Conversely, setting stepRatioControl to 0.1 brings the y-axis domain closer to [0, 1600].
Regardless of the parameter chosen, the step sizes within the domain remain even and will have "nice" values.
Adjusting this parameter is recommended only when a minor change to the dataset's maximum/minimum values causes the default domain to shift dramatically.`,
options: ['0.01', '0.03', '0.05'],
control: {
type: 'select',
},
table: {
type: {
summary: 'number',
},
category: 'General',
},
},
cx: {
description: 'The x-coordinate of the center of the circle.',
table: {
type: {
summary: 'number',
},
category: 'Polar',
},
},
cy: {
description: 'The y-coordinate of the center of the circle.',
table: {
type: {
summary: 'number',
},
category: 'Polar',
},
},
defaultShowTooltip: {
description: 'If true set, the tooltip will be displayed when the chart is rendered.',
table: {
type: {
summary: 'boolean',
},
category: 'General',
},
},
endAngle: { description: 'The end angle of polar chart.', table: { type: { summary: 'Number' }, category: 'Polar' } },
id: {
description: 'The unique id of chart.',
table: {
type: {
summary: 'String',
},
category: 'General',
},
},
innerRadius: {
description: 'The inner radius of polar chart.',
table: {
type: {
summary: 'Number',
},
category: 'Polar',
},
},
layout: {
description: 'The layout of areas, bars, lines in the chart.',
table: {
type: {
summary: "'horizontal' | 'vertical'",
},
defaultValue: "'horizontal'",
category: 'General',
},
},
maxBarSize: {
description: 'The maximum size of bar.',
table: {
type: {
summary: 'number',
},
category: 'Bar',
},
},
onClick,
onMouseDown,
onMouseEnter,
onMouseLeave,
onMouseMove,
onMouseUp,
outerRadius: {
description: 'The outer radius of polar chart.',
table: {
type: {
summary: 'Number',
},
category: 'Polar',
},
},
reverseStackOrder: {
description: `If false set, stacked items will be rendered left to right. If true set, stacked items
will be rendered right to left. (Render direction affects SVG layering, not x position.)`,
table: {
type: {
summary: 'boolean',
},
defaultValue: false,
category: 'General',
},
},
stackOffset: {
description: `Determines how values are stacked:
- \`none\` is the default, it adds values on top of each other. No smarts. Negative values will overlap.
- \`expand\` make it so that the values always add up to 1 - so the chart will look like a rectangle.
- \`wiggle\` and \`silhouette\` tries to keep the chart centered.
- \`sign\` stacks positive values above zero and negative values below zero. Similar to \`none\` but handles negatives.
- \`positive\` ignores all negative values, and then behaves like \`none\`.
Also see https://d3js.org/d3-shape/stack#stack-offsets
(note that the \`diverging\` offset in d3 is named \`sign\` in recharts)
`,
table: {
type: {
summary: "'expand' | 'none' | 'wiggle' | 'silhouette' | 'sign' | 'positive'",
},
defaultValue: "'none'",
category: 'General',
},
},
startAngle: {
description: 'The start angle of polar chart.',
table: { type: { summary: 'Number' }, category: 'Polar' },
},
syncId: {
description: `If any two categorical charts(LineChart, AreaChart, BarChart, ComposedChart) have the same syncId,
these two charts can sync the position tooltip, and the startIndex, endIndex of Brush.`,
table: {
type: {
summary: 'String',
},
category: 'General',
},
},
syncMethod: {
description: `When syncId is provided, allows customization of how the charts will synchronize tooltips and
brushes. Using 'index' (default setting), other charts will reuse current datum's index within the data array.
In cases where data does not have the same length, this might yield unexpected results. In that case use 'value'
which will try to match other charts values, or a fully custom function which will receive tick, data as argument
and should return an index.`,
table: {
type: {
summary: "'index' | 'value' | function",
},
defaultValue: "'index'",
category: 'General',
},
},
throttleDelay: {
description: `The delay of throttle for mouse events, which can be used to avoid
the performance problem when the chart is rendered in a heavy environment.`,
table: {
type: {
summary: 'Number',
},
category: 'General',
},
},
title: {
description: 'The title of chart.',
table: {
type: {
summary: 'String',
},
category: 'General',
},
},
};