Skip to content

Commit 0bb1a2b

Browse files
committed
migrate RadarChart
1 parent a460435 commit 0bb1a2b

File tree

5 files changed

+137
-148
lines changed

5 files changed

+137
-148
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { ControlsWithNote, DocsHeader, Footer } from '@sb/components';
2+
import { Canvas, Meta } from '@storybook/addon-docs';
3+
import * as ComponentStories from './RadarChart.stories';
4+
5+
<Meta of={ComponentStories} />
6+
7+
<DocsHeader />
8+
9+
## Example
10+
11+
<Canvas of={ComponentStories.Default} />
12+
13+
## Properties
14+
15+
<ControlsWithNote of={ComponentStories.Default} />
16+
17+
<br />
18+
<br />
19+
20+
## More Examples
21+
22+
### With Custom Color
23+
24+
<Canvas of={ComponentStories.WithCustomColor} />
25+
26+
### With Data Labels
27+
28+
<Canvas of={ComponentStories.WithDataLabels} />
29+
30+
### Polygon
31+
32+
<Canvas of={ComponentStories.Polygon} />
33+
34+
### Loading Placeholder
35+
36+
<Canvas of={ComponentStories.LoadingPlaceholder} />
37+
38+
<Footer />

packages/charts/src/components/RadarChart/RadarChart.stories.mdx

Lines changed: 0 additions & 144 deletions
This file was deleted.
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import type { Meta, StoryObj } from '@storybook/react';
2+
import { complexDataSet, simpleDataSet } from '../../resources/DemoProps.js';
3+
import { RadarChart } from './RadarChart.js';
4+
5+
const meta = {
6+
title: 'RadarChart',
7+
component: RadarChart,
8+
args: {
9+
dimensions: [
10+
{
11+
accessor: 'name',
12+
formatter: (d) => `${d} 2019`
13+
}
14+
],
15+
measures: [
16+
{
17+
accessor: 'users',
18+
label: 'Users',
19+
formatter: (val) => val.toLocaleString()
20+
},
21+
{
22+
accessor: 'sessions',
23+
label: 'Active Sessions',
24+
formatter: (val) => `${val} sessions`,
25+
hideDataLabel: true
26+
},
27+
{
28+
accessor: 'volume',
29+
label: 'Vol.'
30+
}
31+
],
32+
dataset: complexDataSet
33+
},
34+
argTypes: {
35+
dataset: {
36+
control: { disable: true }
37+
}
38+
}
39+
} satisfies Meta<typeof RadarChart>;
40+
41+
export default meta;
42+
type Story = StoryObj<typeof meta>;
43+
44+
export const Default: Story = {};
45+
46+
export const WithCustomColor: Story = {
47+
args: {
48+
dimensions: [{ accessor: 'name' }],
49+
measures: [{ accessor: 'users', color: 'red' }],
50+
dataset: simpleDataSet
51+
}
52+
};
53+
54+
export const WithDataLabels: Story = {
55+
args: {
56+
dimensions: [{ accessor: 'name' }],
57+
measures: [
58+
{
59+
accessor: 'users'
60+
},
61+
{
62+
accessor: 'sessions'
63+
},
64+
{
65+
accessor: 'volume'
66+
}
67+
]
68+
}
69+
};
70+
71+
export const Polygon: Story = {
72+
args: {
73+
dimensions: [{ accessor: 'name', formatter: (element) => element.slice(0, 3) }],
74+
measures: [
75+
{
76+
accessor: 'users',
77+
formatter: (element) => `${element / 10}`,
78+
label: 'number of users'
79+
},
80+
{
81+
accessor: 'sessions'
82+
},
83+
{
84+
accessor: 'volume'
85+
}
86+
],
87+
chartConfig: { polarGridType: 'polygon' }
88+
}
89+
};
90+
91+
export const LoadingPlaceholder: Story = {
92+
args: {
93+
dataset: []
94+
}
95+
};

packages/charts/src/components/RadarChart/RadarChart.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,23 @@ export interface RadarChartProps extends IChartBaseProps {
3535
/**
3636
* An array of config objects. Each object will define one dimension of the chart.
3737
*
38-
* #### Required Properties
38+
* **Required Properties*
3939
* - `accessor`: string containing the path to the dataset key the dimension should display. Supports object structures by using <code>'parent.child'</code>.
4040
* Can also be a getter.
4141
*
42-
* #### Optional Properties
42+
* **Optional Properties**
4343
* - `formatter`: function will be called for each data label and allows you to format it according to your needs
4444
*
4545
*/
4646
dimensions: IChartDimension[];
4747
/**
4848
* An array of config objects. Each object is defining one radar in the chart.
4949
*
50-
* #### Required properties
50+
* **Required properties**
5151
* - `accessor`: string containing the path to the dataset key this radar should display. Supports object structures by using <code>'parent.child'</code>.
5252
* Can also be a getter.
5353
*
54-
* #### Optional properties
54+
* **Optional properties**
5555
*
5656
* - `label`: Label to display in legends or tooltips. Falls back to the <code>accessor</code> if not present.
5757
* - `color`: any valid CSS Color or CSS Variable. Defaults to the `sapChart_Ordinal` colors

packages/charts/src/components/RadialChart/RadialChart.stories.tsx

Whitespace-only changes.

0 commit comments

Comments
 (0)