-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHealthRadialBarChart.tsx
More file actions
63 lines (59 loc) · 1.71 KB
/
Copy pathHealthRadialBarChart.tsx
File metadata and controls
63 lines (59 loc) · 1.71 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
51
52
53
54
55
56
57
58
59
60
61
62
63
import * as React from 'react';
import { RadialBarChart } from '@mui/x-charts-premium/RadialBarChart';
const healthData = [
{ metric: 'Water', value: 5, goal: 8, color: '#00bcd4' },
{ metric: 'Sleep', value: 6.5, goal: 8, color: '#3f51b5' },
{ metric: 'Calories', value: 540, goal: 700, color: '#ff9800' },
{ metric: 'Activity', value: 42, goal: 60, color: '#4caf50' },
{ metric: 'Steps', value: 8200, goal: 10000, color: '#e91e63' },
];
const dataset = healthData.map((d) => ({
metric: d.metric,
progress: Math.round((d.value / d.goal) * 100),
}));
const highlightScope = { highlight: 'none', fade: 'none' } as const;
export default function HealthRadialBarChart() {
return (
<RadialBarChart
height={400}
dataset={dataset}
series={[
{
dataKey: 'progress',
layout: 'horizontal',
label: 'Progress',
highlightScope,
valueFormatter: (value) => `${value}%`,
},
]}
radiusAxis={[
{
scaleType: 'band',
dataKey: 'metric',
categoryGapRatio: 0.3,
disableLine: true,
disableTicks: true,
colorMap: {
type: 'ordinal',
values: healthData.map((d) => d.metric),
colors: healthData.map((d) => d.color),
},
},
]}
rotationAxis={[
{
scaleType: 'linear',
disableTickLabel: true,
disableLine: true,
disableTicks: true,
min: 0,
max: 100,
valueFormatter: (value) => `${value}%`,
},
]}
axisHighlight={{ rotation: 'none', radius: 'none' }}
hideLegend
slotProps={{ tooltip: { trigger: 'none' } }}
/>
);
}