Skip to content

Commit 4e6b2ad

Browse files
committed
chore(chart box plot) - convert to typescript
1 parent c1321c8 commit 4e6b2ad

File tree

2 files changed

+46
-34
lines changed

2 files changed

+46
-34
lines changed

packages/react-charts/src/victory/components/ChartBoxPlot/examples/ChartBoxPlot.md

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -24,41 +24,8 @@ The examples below are based on the [Victory](https://formidable.com/open-source
2424

2525
## Examples
2626
### Basic with right aligned legend
27-
```js
28-
import { Chart, ChartAxis, ChartBoxPlot, ChartThemeColor } from '@patternfly/react-charts/victory';
27+
```ts file = "ChartBoxPlotBasic.tsx"
2928

30-
<div style={{ height: '300px', width: '750px' }}>
31-
<Chart
32-
ariaDesc="Average number of pets"
33-
ariaTitle="Bar chart example"
34-
domain={{y: [0, 12]}}
35-
domainPadding={{ x: [30, 25] }}
36-
legendData={[{ name: 'Cats' }]}
37-
legendOrientation="vertical"
38-
legendPosition="right"
39-
height={300}
40-
name="chart3"
41-
padding={{
42-
bottom: 50,
43-
left: 50,
44-
right: 200, // Adjusted to accommodate legend
45-
top: 50
46-
}}
47-
themeColor={ChartThemeColor.blue}
48-
width={750}
49-
>
50-
<ChartAxis />
51-
<ChartAxis dependentAxis showGrid />
52-
<ChartBoxPlot
53-
data={[
54-
{ name: 'Cats', x: '2015', y: [1, 2, 3, 5] },
55-
{ name: 'Cats', x: '2016', y: [3, 2, 8, 10] },
56-
{ name: 'Cats', x: '2017', y: [2, 8, 6, 5] },
57-
{ name: 'Cats', x: '2018', y: [1, 3, 2, 9] }
58-
]}
59-
/>
60-
</Chart>
61-
</div>
6229
```
6330

6431
### Labels with bottom aligned legend
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { Chart, ChartAxis, ChartBoxPlot, ChartThemeColor } from '@patternfly/react-charts/victory';
2+
3+
interface PetData {
4+
name: string;
5+
x: string;
6+
y: number[];
7+
}
8+
9+
export const ChartBoxPlotBasic: React.FunctionComponent = () => {
10+
const catsData: PetData[] = [
11+
{ name: 'Cats', x: '2015', y: [1, 2, 3, 5] },
12+
{ name: 'Cats', x: '2016', y: [3, 2, 8, 10] },
13+
{ name: 'Cats', x: '2017', y: [2, 8, 6, 5] },
14+
{ name: 'Cats', x: '2018', y: [1, 3, 2, 9] }
15+
];
16+
17+
const legendData = [{ name: 'Cats' }];
18+
return (
19+
<div style={{ height: '300px', width: '750px' }}>
20+
<Chart
21+
ariaDesc="Average number of pets"
22+
ariaTitle="Bar chart example"
23+
domain={{ y: [0, 12] }}
24+
domainPadding={{ x: [30, 25] }}
25+
legendData={legendData}
26+
legendOrientation="vertical"
27+
legendPosition="right"
28+
height={300}
29+
name="chart3"
30+
padding={{
31+
bottom: 50,
32+
left: 50,
33+
right: 200, // Adjusted to accommodate legend
34+
top: 50
35+
}}
36+
themeColor={ChartThemeColor.blue}
37+
width={750}
38+
>
39+
<ChartAxis />
40+
<ChartAxis dependentAxis showGrid />
41+
<ChartBoxPlot data={catsData} />
42+
</Chart>
43+
</div>
44+
);
45+
};

0 commit comments

Comments
 (0)