1
This commit is contained in:
@@ -4,6 +4,7 @@ import ReactECharts from "echarts-for-react";
|
||||
import { useSelector } from "react-redux";
|
||||
import { useState } from "react";
|
||||
import * as echarts from "echarts";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
function Dust(props) {
|
||||
const dayTrend = useSelector((state) => state.smoke?.dayTrend);
|
||||
@@ -11,7 +12,11 @@ function Dust(props) {
|
||||
const monthTrend = useSelector((state) => state.smoke?.monthTrend);
|
||||
const yearTrend = useSelector((state) => state.smoke?.yearTrend);
|
||||
const [period, setPeriod] = useState("日");
|
||||
|
||||
const [timestr, setTimestr] = useState(
|
||||
dayjs().subtract(7, "day").format("YYYY.MM.DD") +
|
||||
" - " +
|
||||
dayjs().subtract(1, "day").format("YYYY.MM.DD")
|
||||
);
|
||||
const currentTrend =
|
||||
period === "日"
|
||||
? dayTrend
|
||||
@@ -27,16 +32,47 @@ function Dust(props) {
|
||||
// console.log('switched ', v);
|
||||
}
|
||||
|
||||
function handleDateChange(v) {
|
||||
setPeriod(v);
|
||||
// console.log('date ', v);
|
||||
|
||||
function handleDateChange(value) {
|
||||
setPeriod(
|
||||
{
|
||||
日: "day",
|
||||
周: "week",
|
||||
月: "month",
|
||||
年: "year",
|
||||
}[value]
|
||||
);
|
||||
setTimestr(
|
||||
{
|
||||
日:
|
||||
dayjs().subtract(1, "day").format("YYYY.MM.DD") +
|
||||
" 7点 - " +
|
||||
dayjs().format("YYYY.MM.DD") +
|
||||
" 7点",
|
||||
年:
|
||||
dayjs().subtract(1, "year").endOf("year").format("YYYY.MM.") +
|
||||
"29 - " +
|
||||
dayjs().endOf("year").format("YYYY.MM.") +
|
||||
"28",
|
||||
周:
|
||||
dayjs().subtract(7, "day").format("YYYY.MM.DD") +
|
||||
" - " +
|
||||
dayjs().subtract(1, "day").format("YYYY.MM.DD"),
|
||||
月:
|
||||
dayjs().subtract(1, "month").format("YYYY.MM.") +
|
||||
"29 - " +
|
||||
dayjs().format("YYYY.MM.") +
|
||||
"28",
|
||||
}[value]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<GraphBase
|
||||
icon="smoke"
|
||||
title="颗粒物"
|
||||
desc="能耗趋势图"
|
||||
desc={`能耗趋势图 ${timestr}`}
|
||||
switchOptions={false}
|
||||
defaultSelect={period}
|
||||
onSwitch={handleSwitch}
|
||||
|
||||
Reference in New Issue
Block a user