forked from patternfly/patternfly-react
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChartLegendBasicRightLegend.tsx
More file actions
41 lines (38 loc) · 1.03 KB
/
ChartLegendBasicRightLegend.tsx
File metadata and controls
41 lines (38 loc) · 1.03 KB
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
import { ChartDonut } from '@patternfly/react-charts/victory';
interface PetData {
x?: string;
y?: number;
name?: string;
}
export const ChartLegendBasicRightLegend: React.FunctionComponent = () => {
const data: PetData[] = [
{ x: 'Cats', y: 35 },
{ x: 'Dogs', y: 55 },
{ x: 'Birds', y: 10 }
];
const legendData: PetData[] = [{ name: 'Cats: 35' }, { name: 'Dogs: 55' }, { name: 'Birds: 10' }];
return (
<div style={{ height: '230px', width: '350px' }}>
<ChartDonut
ariaDesc="Average number of pets"
ariaTitle="Donut chart example"
constrainToVisibleArea
data={data}
labels={({ datum }) => `${datum.x}: ${datum.y}%`}
legendData={legendData}
legendOrientation="vertical"
legendPosition="right"
name="chart1"
padding={{
bottom: 20,
left: 20,
right: 140, // Adjusted to accommodate legend
top: 20
}}
subTitle="Pets"
title="100"
width={350}
/>
</div>
);
};