Skip to content

Commit d8fd769

Browse files
committedSep 11, 2021
feat(radial-bar): improve documentation about the data structure
1 parent d4f8c47 commit d8fd769

File tree

1 file changed

+116
-17
lines changed
  • website/src/data/components/radial-bar

1 file changed

+116
-17
lines changed
 

‎website/src/data/components/radial-bar/props.ts

+116-17
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,61 @@ const props: ChartProperty[] = [
66
{
77
key: 'data',
88
group: 'Base',
9-
type: 'RadialBarSerie[]',
9+
type: 'object[]',
1010
required: true,
1111
help: 'Chart data.',
1212
description: `
13-
For example, given this config:
13+
Here is what the data for a single chart with 2 bars would look like:
14+
15+
\`\`\`
16+
[
17+
{
18+
id: 'Fruits',
19+
data: [{ x: 'Apples', y: 32 }]
20+
},
21+
{
22+
id: 'Vegetables',
23+
data: [{ x: 'Eggplants', y: 27 }]
24+
}
25+
]
26+
\`\`\`
27+
28+
You can add several metrics per group:
29+
1430
\`\`\`
1531
[
16-
{ language: 'javascript', john: 12, sarah: 32, bob: 27 },
17-
{ language: 'golang', john: 25, sarah: 15, bob: 3 },
18-
{ language: 'python', john: 5, sarah: 22, bob: 31 },
19-
{ language: 'java', john: 19, sarah: 17, bob: 9 }
32+
{
33+
id: 'Fruits',
34+
data: [
35+
{ x: 'Apples', y: 32 },
36+
{ x: 'Mangoes', y: 15 }
37+
]
38+
},
39+
{
40+
id: 'Vegetables',
41+
data: [
42+
{ x: 'Eggplants', y: 27 },
43+
{ x: 'Avocados', y: 34 }
44+
]
45+
}
2046
]
21-
keys: ['john', 'sarah', 'bob']
22-
indexBy: 'language'
2347
\`\`\`
24-
We'll have a radar chart representing programing
25-
skills for each user by language
26-
(3 layers and 4 dimensions).
48+
49+
When a bar is computed, the \`id\` is going to be added
50+
as the \`groupId\`, \`x\` as the \`category\` and \`y\`
51+
as the value, for example the first bar for the number of Apples
52+
in the Fruits group would be:
53+
54+
\`\`\`
55+
{
56+
groupId: 'Fruits',
57+
category: 'Apples',
58+
value: 32
59+
}
60+
\`\`\`
61+
62+
You might read those values when adding an \`onClick\` handler
63+
for example, or when customizing the tooltip.
2764
`,
2865
flavors: ['svg'],
2966
},
@@ -32,7 +69,7 @@ const props: ChartProperty[] = [
3269
group: 'Base',
3370
type: 'string | (value: number) => string',
3471
required: false,
35-
help: 'Optional formatter for values.',
72+
help: 'Optional formatter for values (`y`).',
3673
description: `
3774
The formatted value can then be used for labels & tooltips.
3875
@@ -102,7 +139,6 @@ const props: ChartProperty[] = [
102139
defaultValue: svgDefaultProps.startAngle,
103140
controlType: 'angle',
104141
controlOptions: {
105-
unit: '°',
106142
min: -180,
107143
max: 360,
108144
step: 5,
@@ -118,7 +154,6 @@ const props: ChartProperty[] = [
118154
defaultValue: svgDefaultProps.endAngle,
119155
controlType: 'angle',
120156
controlOptions: {
121-
unit: '°',
122157
min: -360,
123158
max: 360,
124159
step: 5,
@@ -178,11 +213,75 @@ const props: ChartProperty[] = [
178213
controlType: 'switch',
179214
},
180215
{
181-
key: 'sliceTooltip',
216+
key: 'tooltip',
217+
group: 'Interactivity',
218+
type: 'RadialBarTooltipComponent',
219+
required: false,
220+
help: 'Override default tooltip.',
221+
flavors: ['svg'],
222+
},
223+
{
224+
key: 'onClick',
225+
group: 'Interactivity',
226+
type: '(bar: ComputedBar, event: MouseEvent) => void',
227+
required: false,
228+
help: 'onClick handler.',
229+
flavors: ['svg'],
230+
},
231+
{
232+
key: 'onMouseEnter',
233+
group: 'Interactivity',
234+
type: '(bar: ComputedBar, event: MouseEvent) => void',
235+
required: false,
236+
help: 'onMouseEnter handler.',
237+
flavors: ['svg'],
238+
},
239+
{
240+
key: 'onMouseMove',
241+
group: 'Interactivity',
242+
type: '(bar: ComputedBar, event: MouseEvent) => void',
243+
required: false,
244+
help: 'onMouseMove handler.',
245+
flavors: ['svg'],
246+
},
247+
{
248+
key: 'onMouseLeave',
182249
group: 'Interactivity',
183-
type: 'FunctionComponent<RadarSliceTooltipProps>',
250+
type: '(bar: ComputedBar, event: MouseEvent) => void',
251+
required: false,
252+
help: 'onMouseLeave handler.',
253+
flavors: ['svg'],
254+
},
255+
{
256+
key: 'role',
257+
group: 'Accessibility',
258+
type: 'string',
259+
required: false,
260+
help: 'Main element role attribute.',
261+
flavors: ['svg'],
262+
},
263+
{
264+
key: 'ariaLabel',
265+
group: 'Accessibility',
266+
type: 'string',
267+
required: false,
268+
help: 'Main element [aria-label](https://www.w3.org/TR/wai-aria/#aria-label).',
269+
flavors: ['svg'],
270+
},
271+
{
272+
key: 'ariaLabelledBy',
273+
group: 'Accessibility',
274+
type: 'string',
275+
required: false,
276+
help: 'Main element [aria-labelledby](https://www.w3.org/TR/wai-aria/#aria-labelledby).',
277+
flavors: ['svg'],
278+
},
279+
{
280+
key: 'ariaDescribedBy',
281+
group: 'Accessibility',
282+
type: 'string',
184283
required: false,
185-
help: 'Override default slice tooltip.',
284+
help: 'Main element [aria-describedby](https://www.w3.org/TR/wai-aria/#aria-describedby).',
186285
flavors: ['svg'],
187286
},
188287
...motionProperties(['svg'], svgDefaultProps, 'react-spring'),

0 commit comments

Comments
 (0)
Please sign in to comment.