65 lines
1.2 KiB
TypeScript
65 lines
1.2 KiB
TypeScript
"use client";
|
|
|
|
import React from "react";
|
|
import {
|
|
Chart as ChartJS,
|
|
CategoryScale,
|
|
LinearScale,
|
|
PointElement,
|
|
LineElement,
|
|
Title,
|
|
Tooltip,
|
|
Legend,
|
|
} from "chart.js";
|
|
import { Line } from "react-chartjs-2";
|
|
import { faker } from "@faker-js/faker";
|
|
|
|
ChartJS.register(
|
|
CategoryScale,
|
|
LinearScale,
|
|
PointElement,
|
|
LineElement,
|
|
Title,
|
|
Tooltip,
|
|
Legend
|
|
);
|
|
|
|
export const options = {
|
|
responsive: true,
|
|
plugins: {
|
|
legend: {
|
|
position: "top" as const,
|
|
},
|
|
title: {
|
|
display: true,
|
|
text: "Chart.js Line Chart",
|
|
},
|
|
},
|
|
};
|
|
|
|
const labels = ["January", "February", "March", "April", "May", "June", "July"];
|
|
|
|
export const data = {
|
|
labels,
|
|
datasets: [
|
|
{
|
|
label: "Dataset 1",
|
|
data: labels.map(() => faker.datatype.number({ min: -1000, max: 1000 })),
|
|
borderColor: "rgb(255, 99, 132)",
|
|
backgroundColor: "rgba(255, 99, 132, 0.5)",
|
|
},
|
|
{
|
|
label: "Dataset 2",
|
|
data: labels.map(() => faker.datatype.number({ min: -1000, max: 1000 })),
|
|
borderColor: "rgb(53, 162, 235)",
|
|
backgroundColor: "rgba(53, 162, 235, 0.5)",
|
|
},
|
|
],
|
|
};
|
|
|
|
export default function LineChart() {
|
|
return (
|
|
<Line options={options} data={data} className=' '/>
|
|
);
|
|
}
|