mediahub-fe/src/app/[locale]/(protected)/charts/appex-charts/charts-appex-pie/basic-pie.tsx

64 lines
1.4 KiB
TypeScript
Raw Normal View History

2024-11-26 03:09:48 +00:00
"use client";
2025-05-27 00:19:52 +00:00
2024-11-26 03:09:48 +00:00
import dynamic from "next/dynamic";
import { useTheme } from "next-themes";
2025-05-27 00:19:52 +00:00
import { colors } from "@/lib/colors";
2025-05-26 22:39:54 +00:00
import { useConfig } from "@/lib/hooks/use-config";
2025-05-27 00:19:52 +00:00
import { hexToRGB } from "@/lib/utils/utils";
const Chart = dynamic(() => import("react-apexcharts"), { ssr: false });
2024-11-26 03:09:48 +00:00
const BasicPie = ({ height = 350 }) => {
const [config] = useConfig();
const { theme: mode } = useTheme();
const series = [44, 55, 13, 43, 22];
const options: any = {
chart: {
toolbar: {
show: false,
},
},
stroke: {
2025-05-27 00:19:52 +00:00
width: 0,
2024-11-26 03:09:48 +00:00
},
labels: ["Team A", "Team B", "Team C", "Team D", "Team E"],
dataLabels: {
enabled: true,
style: {
fontSize: "20px",
},
},
2025-05-27 00:19:52 +00:00
colors: [colors.primary, colors.info, colors.success, colors.primary, colors.secondary],
2024-11-26 03:09:48 +00:00
tooltip: {
theme: mode === "dark" ? "dark" : "light",
},
padding: {
top: 0,
right: 0,
bottom: 0,
left: 0,
},
legend: {
labels: {
2025-05-27 00:19:52 +00:00
colors: mode === "light" ? colors["default-600"] : colors["default-300"],
2024-11-26 03:09:48 +00:00
},
itemMargin: {
horizontal: 5,
vertical: 5,
},
markers: {
width: 10,
height: 10,
radius: 10,
2025-05-27 00:19:52 +00:00
offsetX: config.isRtl ? 5 : -5,
},
2024-11-26 03:09:48 +00:00
},
};
2025-05-27 00:19:52 +00:00
return <Chart options={options} series={series} type="pie" height={height} width={"100%"} />;
2024-11-26 03:09:48 +00:00
};
export default BasicPie;