Compare commits
No commits in common. "ed2e03e2023d6f9a89b284978e48373028014f01" and "3ee0c3a02ca90e9abf7494b82cc1529e1f6388d0" have entirely different histories.
ed2e03e202
...
3ee0c3a02c
|
|
@ -2,12 +2,13 @@ import React from 'react';
|
||||||
import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer } from 'recharts';
|
import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer } from 'recharts';
|
||||||
|
|
||||||
const SystemStatusChart = ({ data }) => {
|
const SystemStatusChart = ({ data }) => {
|
||||||
|
// Обрезаем массив, оставляя только последние 20 точек
|
||||||
const trimmedData = data.slice(-20);
|
const trimmedData = data.slice(-20);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ResponsiveContainer width="100%" height={300}>
|
<ResponsiveContainer width="100%" height={300}>
|
||||||
<LineChart
|
<LineChart
|
||||||
data={trimmedData}
|
data={trimmedData} // Используем обрезанный массив
|
||||||
margin={{
|
margin={{
|
||||||
top: 5, right: 30, left: 20, bottom: 5,
|
top: 5, right: 30, left: 20, bottom: 5,
|
||||||
}}
|
}}
|
||||||
|
|
@ -17,13 +18,7 @@ const SystemStatusChart = ({ data }) => {
|
||||||
<YAxis domain={[0, 100]} />
|
<YAxis domain={[0, 100]} />
|
||||||
<Tooltip />
|
<Tooltip />
|
||||||
<Legend />
|
<Legend />
|
||||||
<Line
|
<Line type="monotone" dataKey="status" stroke="#8884d8" activeDot={{ r: 8 }} />
|
||||||
type="monotone"
|
|
||||||
dataKey="status"
|
|
||||||
stroke="#8884d8"
|
|
||||||
activeDot={{ r: 8 }}
|
|
||||||
name=""
|
|
||||||
/>
|
|
||||||
</LineChart>
|
</LineChart>
|
||||||
</ResponsiveContainer>
|
</ResponsiveContainer>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -5,22 +5,6 @@ const SystemStatusChart = ({ data }) => {
|
||||||
// Обрезаем массив, оставляя только последние 20 точек
|
// Обрезаем массив, оставляя только последние 20 точек
|
||||||
const trimmedData = data.slice(-20);
|
const trimmedData = data.slice(-20);
|
||||||
|
|
||||||
const CustomTooltip = ({ active, payload, label }) => {
|
|
||||||
if (active && payload && payload.length) {
|
|
||||||
return (
|
|
||||||
<div className="custom-tooltip" style={{
|
|
||||||
backgroundColor: '#fff',
|
|
||||||
padding: '10px',
|
|
||||||
border: '1px solid #ccc'
|
|
||||||
}}>
|
|
||||||
<p>{`Время: ${label}`}</p>
|
|
||||||
<p>{`Значение: ${payload[0].value}`}</p>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ResponsiveContainer width="100%" height={300}>
|
<ResponsiveContainer width="100%" height={300}>
|
||||||
<LineChart
|
<LineChart
|
||||||
|
|
@ -32,7 +16,8 @@ const SystemStatusChart = ({ data }) => {
|
||||||
<CartesianGrid strokeDasharray="3 3" />
|
<CartesianGrid strokeDasharray="3 3" />
|
||||||
<XAxis dataKey="time" />
|
<XAxis dataKey="time" />
|
||||||
<YAxis domain={[0, 100]} />
|
<YAxis domain={[0, 100]} />
|
||||||
<Tooltip content={<CustomTooltip />} />
|
<Tooltip />
|
||||||
|
<Legend />
|
||||||
<Line type="monotone" dataKey="status" stroke="#8884d8" activeDot={{ r: 8 }} />
|
<Line type="monotone" dataKey="status" stroke="#8884d8" activeDot={{ r: 8 }} />
|
||||||
</LineChart>
|
</LineChart>
|
||||||
</ResponsiveContainer>
|
</ResponsiveContainer>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue