Skip to content

Commit 1fe4a03

Browse files
committed
Revert "remove pie element"
This reverts commit f939fcd.
1 parent f939fcd commit 1fe4a03

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

src/configuration.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ const defaultConf: Config = [
2424
labels: [Label.amt, Label.uv],
2525
},
2626
},
27+
{
28+
type: "pie",
29+
props: {
30+
labels: [Label.pv, Label.uv, Label.amt],
31+
},
32+
},
2733
{
2834
type: "gauge",
2935
props: {
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { PieChart } from "@mui/x-charts";
2+
import { getLatest } from "../helpers";
3+
import { Type, type Static } from "@sinclair/typebox";
4+
import { labelSchema } from "../../labels";
5+
6+
export const slug = "pie";
7+
8+
export const jsonSchema = Type.Object(
9+
{
10+
type: Type.Literal(slug),
11+
props: Type.Object({
12+
labels: Type.Array(labelSchema, {
13+
title: "Pie Chart Labels",
14+
description: "The labels to display on the pie chart",
15+
}),
16+
fullPage: Type.Optional(
17+
Type.Boolean({
18+
title: "Should the chart occupy the full page?",
19+
}),
20+
),
21+
}),
22+
},
23+
{
24+
title: "Pie Chart",
25+
description: "A simple pie chart",
26+
},
27+
);
28+
29+
type PieChartSchema = Static<typeof jsonSchema>;
30+
31+
export function Component({ labels, fullPage }: PieChartSchema["props"]) {
32+
return (
33+
<PieChart
34+
series={[
35+
{
36+
arcLabel: (item) => `${item.value}`,
37+
startAngle: -90,
38+
endAngle: 90,
39+
data: labels.map((label) => ({ label, value: getLatest(label) })),
40+
},
41+
]}
42+
height={fullPage ? 800 : 300}
43+
/>
44+
);
45+
}

src/lib/chartComponents/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ import * as SimpleLineChart from "./SimpleLineChart";
22
import * as SimpleGauge from "./SimpleGauge";
33
import * as SimpleBarChart from "./SimpleBarChart";
44
import * as StackedAreaChart from "./StackedAreaChart";
5+
import * as StraightAnglePieChart from "./StraightAnglePieChart";
56

67
export const charts = [
78
SimpleLineChart,
89
SimpleGauge,
910
SimpleBarChart,
1011
StackedAreaChart,
12+
StraightAnglePieChart,
1113
] as const;

0 commit comments

Comments
 (0)