Files
hackaton-2025-web-frontend/src/misc/CpuChart.js
Vyacheslav K b28022c633 some updates
2025-05-07 15:43:49 +03:00

55 lines
860 B
JavaScript

import React from 'react';
import {
Chart as ChartJS,
CategoryScale,
LinearScale,
PointElement,
LineElement,
Title,
Tooltip,
Legend,
} from 'chart.js';
import { Line } from 'react-chartjs-2';
ChartJS.register(
CategoryScale,
LinearScale,
PointElement,
LineElement,
Title,
Tooltip,
Legend
);
const options = {
responsive: true,
plugins: {
legend: {
display: false,
},
title: {
display: false,
},
},
};
export default function CpuChart({chart_dataset}) {
const labels = Object.keys(chart_dataset);
const data = {
labels,
datasets: [
{
label: 'Загрузка CPU',
data: Object.values(chart_dataset),
borderColor: '#ff9f43',
backgroundColor: 'rgba(255, 99, 132, 0.5)',
}
],
};
return <Line options={options} data={data} />;
}