ag visual farm added to the dev branch field related stuff not imported yet, and the geocoder has some bugs with the new version
This commit is contained in:
parent
b4da0d6859
commit
022925d7d7
41 changed files with 8895 additions and 79 deletions
43
src/charts/MiniPie.tsx
Normal file
43
src/charts/MiniPie.tsx
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
import { useEffect, useState } from "react";
|
||||
import { Cell, Pie, PieChart, ResponsiveContainer } from "recharts";
|
||||
|
||||
interface Props {
|
||||
max: number;
|
||||
current: number;
|
||||
colour: string;
|
||||
size: number;
|
||||
}
|
||||
|
||||
interface Data {
|
||||
key: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
export default function MiniPie(props: Props) {
|
||||
const [data, setData] = useState<Data[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
let data: Data[] = [];
|
||||
data.push({ key: "current", value: props.current });
|
||||
setData(data);
|
||||
}, [props]);
|
||||
|
||||
return (
|
||||
<ResponsiveContainer width={props.size}>
|
||||
<PieChart style={{ cursor: "pointer" }}>
|
||||
<Pie
|
||||
outerRadius={"100%"}
|
||||
data={data}
|
||||
dataKey="value"
|
||||
cx="50%"
|
||||
cy="50%"
|
||||
startAngle={-90}
|
||||
endAngle={(props.current / props.max) * -360 - 90}>
|
||||
{data.map((entry: Data, index: number) => (
|
||||
<Cell key={`cell-${index}`} fill={props.colour} />
|
||||
))}
|
||||
</Pie>
|
||||
</PieChart>
|
||||
</ResponsiveContainer>
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue