import React, { useState } from 'react'; import { Button, Form, Select, Card, Typography, DatePicker } from 'antd'; import { useQuery, } from '@tanstack/react-query'; import dayjs from 'dayjs'; import { Line } from "@ant-design/plots"; import 'dayjs/locale/zh-cn'; import { bigClient } from '@/client/api'; interface ChartTooltipInfo { items: Array>; title: string; } // 告警数据变化图表页面 export const AlertTrendChartPage = () => { const [timeRange, setTimeRange] = useState<[dayjs.Dayjs, dayjs.Dayjs]>([ dayjs().subtract(1, 'day').startOf('day'), dayjs().endOf('day') ]); const [dimension, setDimension] = useState<'hour' | 'day' | 'month'>('hour'); const { data: alarmData, isLoading, refetch } = useQuery({ queryKey: ['adminZichanAlarm', timeRange, dimension], queryFn: async () => { const res = await bigClient.charts['zichan-alarm'].$get({ query:{ startTime: timeRange[0].toDate(), endTime: timeRange[1].toDate(), timeUnit: dimension } }) if(res.status !== 200) throw new Error('数据查询失败'); return await res.json(); } }); const { Title } = Typography; const { RangePicker } = DatePicker; const handleSearch = () => { refetch(); }; return (
告警数据趋势
dates && setTimeRange(dates as [dayjs.Dayjs, dayjs.Dayjs])} showTime />