fix(dashboard): daily-графики и счётчики из GET /v1/admin/stats
Refs EventHub/EventHubFrontAdmin#26 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import React from 'react';
|
||||
import { Card, Col } from 'antd';
|
||||
import {
|
||||
LineChart,
|
||||
Line,
|
||||
XAxis,
|
||||
YAxis,
|
||||
CartesianGrid,
|
||||
Tooltip,
|
||||
Legend,
|
||||
ResponsiveContainer,
|
||||
} from 'recharts';
|
||||
import { DayCount } from '../types/api';
|
||||
|
||||
interface Props {
|
||||
title: string;
|
||||
data?: DayCount[];
|
||||
color: string;
|
||||
lg?: number;
|
||||
}
|
||||
|
||||
const DailyLineChartCard: React.FC<Props> = ({ title, data, color, lg = 12 }) => {
|
||||
const chartData = (data ?? []).map((item) => ({
|
||||
date: item.date,
|
||||
count: item.count,
|
||||
}));
|
||||
|
||||
if (chartData.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<Col xs={24} lg={lg}>
|
||||
<Card title={title}>
|
||||
<ResponsiveContainer width="100%" height={300}>
|
||||
<LineChart data={chartData}>
|
||||
<CartesianGrid strokeDasharray="3 3" />
|
||||
<XAxis dataKey="date" />
|
||||
<YAxis allowDecimals={false} />
|
||||
<Tooltip />
|
||||
<Legend />
|
||||
<Line type="monotone" dataKey="count" stroke={color} name={title} />
|
||||
</LineChart>
|
||||
</ResponsiveContainer>
|
||||
</Card>
|
||||
</Col>
|
||||
);
|
||||
};
|
||||
|
||||
export default DailyLineChartCard;
|
||||
Reference in New Issue
Block a user