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

87 lines
1.9 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 { getGridConfig } from "@/lib/utils/appex-chart-options";
import { colors } from "@/lib/utils/colors";
2025-05-27 00:19:52 +00:00
import { useConfig } from "@/lib/hooks/use-config";
import { hexToRGB } from "@/lib/utils/utils";
const Chart = dynamic(() => import("react-apexcharts"), { ssr: false });
2024-11-26 03:09:48 +00:00
const PyramidChart = ({ height = 350 }) => {
const [config] = useConfig();
const { theme: mode } = useTheme();
const series = [
{
name: "",
data: [200, 330, 548, 740, 880, 990, 1100, 1380],
},
];
const options: any = {
chart: {
toolbar: {
show: false,
},
},
plotOptions: {
bar: {
borderRadius: 0,
horizontal: true,
distributed: true,
barHeight: "100%",
isFunnel: true,
},
},
dataLabels: {
enabled: true,
formatter: function (val: string, opt: any) {
return opt.w.globals.labels[opt.dataPointIndex] + ": " + val;
},
dropShadow: {
enabled: true,
},
},
2025-05-27 00:19:52 +00:00
colors: [colors.primary, colors.info, colors.primary, colors.success],
2024-11-26 03:09:48 +00:00
tooltip: {
theme: mode === "dark" ? "dark" : "light",
},
grid: getGridConfig(),
fill: {
type: "gradient",
2025-05-27 00:19:52 +00:00
colors: [colors.primary, colors.info, colors.primary, colors.success],
2024-11-26 03:09:48 +00:00
},
yaxis: {
show: false,
},
xaxis: {
categories: [
"Sweets",
"Processed Foods",
"Healthy Fats",
"Meat",
"Beans & Legumes",
"Dairy",
"Fruits & Vegetables",
"Grains",
],
},
legend: {
show: false,
},
padding: {
top: 0,
right: 0,
bottom: 0,
left: 0,
},
};
2025-05-27 00:19:52 +00:00
return <Chart options={options} series={series} type="bar" height={height} width={"100%"} />;
2024-11-26 03:09:48 +00:00
};
export default PyramidChart;