61 lines
1.1 KiB
TypeScript
61 lines
1.1 KiB
TypeScript
"use client"
|
|
|
|
import React from 'react';
|
|
import {
|
|
Chart as ChartJS,
|
|
CategoryScale,
|
|
LinearScale,
|
|
BarElement,
|
|
Title,
|
|
Tooltip,
|
|
Legend,
|
|
} from 'chart.js';
|
|
import { Bar } from 'react-chartjs-2';
|
|
import { faker } from "@faker-js/faker";
|
|
|
|
ChartJS.register(
|
|
CategoryScale,
|
|
LinearScale,
|
|
BarElement,
|
|
Title,
|
|
Tooltip,
|
|
Legend
|
|
);
|
|
|
|
export const options = {
|
|
responsive: true,
|
|
plugins: {
|
|
legend: {
|
|
position: 'top' as const,
|
|
},
|
|
title: {
|
|
display: true,
|
|
text: 'Chart.js Bar 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: 0, max: 1000 })),
|
|
backgroundColor: 'rgba(255, 99, 132, 0.5)',
|
|
},
|
|
{
|
|
label: 'Dataset 2',
|
|
data: labels.map(() => faker.datatype.number({ min: 0, max: 1000 })),
|
|
backgroundColor: 'rgba(53, 162, 235, 0.5)',
|
|
},
|
|
],
|
|
};
|
|
|
|
export function VerticalChart() {
|
|
return (
|
|
<Bar options={options} data={data} className='!w-full !h-full'/>
|
|
)
|
|
}
|