101 lines
1.7 KiB
TypeScript
101 lines
1.7 KiB
TypeScript
"use client";
|
|
|
|
import {
|
|
Chart as ChartJS,
|
|
CategoryScale,
|
|
LinearScale,
|
|
LineElement,
|
|
Title,
|
|
Tooltip,
|
|
Legend,
|
|
PointElement,
|
|
} from "chart.js";
|
|
import { colors } from "@/lib/colors";
|
|
|
|
import { useTheme } from "next-themes";
|
|
import { hexToRGB } from "@/lib/utils";
|
|
|
|
import { Line } from "react-chartjs-2";
|
|
|
|
|
|
ChartJS.register(
|
|
CategoryScale,
|
|
LinearScale,
|
|
LineElement,
|
|
Title,
|
|
Tooltip,
|
|
Legend,
|
|
PointElement
|
|
);
|
|
|
|
const SteppedLineCharts = ({ height = 350 }) => {
|
|
|
|
const { theme: mode } = useTheme();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const labels = ["Day 1", "Day 2", "Day 3", "Day 4", "Day 5", "Day 6"];
|
|
|
|
const data: any = {
|
|
labels: labels,
|
|
datasets: [
|
|
{
|
|
label: "Dataset",
|
|
data: labels.map(() => -12),
|
|
borderColor: hexToRGB(colors.danger, 0.5),
|
|
fill: false,
|
|
stepped: true,
|
|
},
|
|
],
|
|
};
|
|
const options: any = {
|
|
responsive: true,
|
|
plugins: {
|
|
legend: {
|
|
labels: {
|
|
color: mode === 'light' ? colors["default-600"] : colors["default-300"],
|
|
},
|
|
},
|
|
},
|
|
|
|
scales: {
|
|
y: {
|
|
border: {
|
|
display: false
|
|
},
|
|
grid: {
|
|
drawTicks: false,
|
|
display: false,
|
|
},
|
|
ticks: {
|
|
color: mode === 'light' ? colors["default-600"] : colors["default-300"],
|
|
},
|
|
},
|
|
x: {
|
|
grid: {
|
|
drawTicks: false,
|
|
display: false,
|
|
},
|
|
|
|
ticks: {
|
|
color: mode === 'light' ? colors["default-600"] : colors["default-300"],
|
|
},
|
|
},
|
|
},
|
|
|
|
maintainAspectRatio: false,
|
|
};
|
|
|
|
return (
|
|
<div>
|
|
<Line options={options} data={data} height={height} />
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default SteppedLineCharts;
|