mediahub-fe/src/app/[locale]/(protected)/charts/appex-charts/charts-appex-column/distributed-chart.tsx

93 lines
2.1 KiB
TypeScript

"use client";
import dynamic from "next/dynamic";
import { useTheme } from "next-themes";
import { getGridConfig, getLabel, getXAxisConfig } from "@/lib/utils/appex-chart-options";
import { colors } from "@/lib/utils/colors";
import { useConfig } from "@/lib/hooks/use-config";
import { hexToRGB } from "@/lib/utils/utils";
const Chart = dynamic(() => import("react-apexcharts"), { ssr: false });
const DistributedChart = ({ height = 300 }) => {
const [config] = useConfig();
const { theme: mode } = useTheme();
const series = [
{
data: [21, 22, 10, 28, 16, 21, 13, 30],
},
];
const options: any = {
chart: {
toolbar: {
show: false,
},
},
dataLabels: {
enabled: false,
},
stroke: {
curve: "smooth",
width: 2,
},
colors: [colors.primary, colors.primary, colors.info],
tooltip: {
theme: mode === "dark" ? "dark" : "light",
},
grid: getGridConfig(),
yaxis: getXAxisConfig(mode === "light" ? colors["default-600"] : colors["default-300"]),
plotOptions: {
bar: {
columnWidth: "45%",
distributed: true,
},
},
xaxis: {
categories: [
["John", "Doe"],
["Joe", "Smith"],
["Jake", "Williams"],
"Amber",
["Peter", "Brown"],
["Mary", "Evans"],
["David", "Wilson"],
["Lily", "Roberts"],
],
labels: getLabel(mode === "light" ? colors["default-600"] : colors["default-300"]),
axisBorder: {
show: false,
},
axisTicks: {
show: false,
},
padding: {
top: 0,
right: 0,
bottom: 0,
left: 0,
},
},
legend: {
labels: {
colors: mode === "light" ? colors["default-600"] : colors["default-300"],
},
itemMargin: {
horizontal: 5,
vertical: 5,
},
markers: {
width: 10,
height: 10,
radius: 10,
offsetX: config.isRtl ? 5 : -5,
},
},
};
return <Chart options={options} series={series} type="bar" height={height} width={"100%"} />;
};
export default DistributedChart;