forked from patternfly/patternfly-react
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChartUtilStaticBottomLegend.tsx
More file actions
50 lines (47 loc) · 1.41 KB
/
ChartUtilStaticBottomLegend.tsx
File metadata and controls
50 lines (47 loc) · 1.41 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
42
43
44
45
46
47
48
49
50
import { ChartDonutThreshold, ChartDonutUtilization } from '@patternfly/react-charts/victory';
interface UsageData {
x?: string;
y?: number;
name?: string;
}
export const ChartUtilStaticBottomLegend: React.FunctionComponent = () => {
const dataThreshold: UsageData[] = [
{ x: 'Warning at 60%', y: 60 },
{ x: 'Danger at 90%', y: 90 }
];
const dataUtil: UsageData = { x: 'Storage capacity', y: 45 };
const legendData: UsageData[] = [
{ name: `Storage capacity: 45%` },
{ name: 'Warning threshold at 60%' },
{ name: 'Danger threshold at 90%' }
];
return (
<div style={{ height: '275px', width: '675px' }}>
<ChartDonutThreshold
ariaDesc="Storage capacity"
ariaTitle="Donut utilization chart with static threshold example"
constrainToVisibleArea
data={dataThreshold}
height={275}
labels={({ datum }) => (datum.x ? datum.x : null)}
name="chart14"
padding={{
bottom: 65, // Adjusted to accommodate legend
left: 20,
right: 20,
top: 20
}}
width={675}
>
<ChartDonutUtilization
data={dataUtil}
labels={({ datum }) => (datum.x ? `${datum.x}: ${datum.y}%` : null)}
legendData={legendData}
legendPosition="bottom"
subTitle="of 100 GBps"
title="45%"
/>
</ChartDonutThreshold>
</div>
);
};