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

118 lines
2.2 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,
getYAxisConfig,
getLabel,
} from "@/lib/appex-chart-options";
const BasicBoxPlot = ({ height = 300 }) => {
const [config] = useConfig();
const { theme: mode } = useTheme();
const series = [
{
type: "boxPlot",
data: [
{
x: "Jan 2015",
y: [54, 66, 69, 75, 88],
},
{
x: "Jan 2016",
y: [43, 65, 69, 76, 81],
},
{
x: "Jan 2017",
y: [31, 39, 45, 51, 59],
},
{
x: "Jan 2018",
y: [39, 46, 55, 65, 71],
},
{
x: "Jan 2019",
y: [29, 31, 35, 39, 44],
},
{
x: "Jan 2020",
y: [41, 49, 58, 61, 67],
},
{
x: "Jan 2021",
y: [54, 59, 66, 71, 88],
},
],
},
];
const options: any = {
chart: {
toolbar: {
show: false,
},
},
dataLabels: {
enabled: false,
},
stroke: {
curve: "smooth",
width: 4,
},
colors: [
colors.primary,
colors.info,
],
tooltip: {
theme: mode === "dark" ? "dark" : "light",
},
plotOptions: {
boxPlot: {
colors: {
upper: colors.info,
lower: colors.success,
},
},
},
grid: getGridConfig(),
yaxis: getYAxisConfig(
mode === 'light' ? colors["default-600"] : colors["default-300"]
),
xaxis: {
type: "datetime",
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,
},
};
return (
<Chart
options={options}
series={series}
type="boxPlot"
height={height}
width={"100%"}
/>
);
};
export default BasicBoxPlot;