mediahub-fe/app/[locale]/(protected)/charts/appex-charts/charts-appex-bar/grouped-bar.tsx

118 lines
2.3 KiB
TypeScript

"use client";
import dynamic from "next/dynamic";
const Chart = dynamic(() => import("react-apexcharts"), { ssr: false });
import { colors } from "@/lib/colors";
import { useTheme } from "next-themes";
import { hexToRGB } from "@/lib/utils";
import { useConfig } from "@/hooks/use-config";
import {
getGridConfig,
getLabel,
getYAxisConfig,
} from "@/lib/appex-chart-options";
const GroupedBar = ({ height = 350 }) => {
const [config] = useConfig();
const { theme: mode } = useTheme();
const series = [
{
data: [44, 55, 41, 64, 22, 43],
},
{
data: [53, 32, 33, 52, 13, 44],
},
];
const options: any = {
chart: {
toolbar: {
show: false,
},
},
plotOptions: {
bar: {
horizontal: true,
dataLabels: {
position: "top",
},
},
},
dataLabels: {
enabled: true,
offsetX: -10,
style: {
fontSize: "12px",
fontWeight: 700,
colors: [
mode === 'light' ? colors["default-600"] : colors["default-300"],
],
},
},
stroke: {
show: false,
width: 1,
colors: [
mode === 'light' ? colors["default-600"] : colors["default-300"],
],
},
colors: [
colors.primary,
colors.info,
],
tooltip: {
theme: mode === "dark" ? "dark" : "light",
},
grid: getGridConfig(),
yaxis: getYAxisConfig(
mode === 'light' ? colors["default-600"] : colors["default-300"]
),
xaxis: {
categories: [2001, 2002, 2003, 2004, 2005, 2006],
axisBorder: {
show: false,
},
axisTicks: {
show: false,
},
labels: getLabel(
mode === 'light' ? colors["default-600"] : colors["default-300"]
),
},
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 GroupedBar;