update 天然气历史
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 { lunarYear } from "../../../../utils/energeChartOption";
|
||||
|
||||
function Gas(props) {
|
||||
const elecTrend = useSelector((state) => state.energy.trend.natGas2);
|
||||
@@ -66,9 +67,20 @@ function Gas(props) {
|
||||
export default Gas;
|
||||
|
||||
function getOptions(period, trend) {
|
||||
console.log("getOptions", period, trend);
|
||||
if (trend[period].length === 0) return null;
|
||||
// export default function getOptions(seriesData, name) {
|
||||
const today = new Date();
|
||||
const currentYear = today.getFullYear();
|
||||
const currentMonth = today.getMonth() + 1;
|
||||
let days = 30;
|
||||
if (period == "month") {
|
||||
if (currentMonth in [1, 3, 5, 7, 8, 10, 12]) {
|
||||
days = 31;
|
||||
} else if (currentMonth == 2) {
|
||||
days = lunarYear(currentYear) ? 29 : 28;
|
||||
}
|
||||
}
|
||||
|
||||
const colors = [
|
||||
"#FFD160",
|
||||
"#12FFF5",
|
||||
@@ -99,14 +111,19 @@ function getOptions(period, trend) {
|
||||
},
|
||||
xAxis: {
|
||||
type: "category",
|
||||
data: Array(period == "week" ? 7 : period == "year" ? 12 : 30)
|
||||
data: Array(period == "week" ? 7 : period == "year" ? 12 : days)
|
||||
.fill(1)
|
||||
.map((_, index) => {
|
||||
const today = new Date();
|
||||
const dtimestamp = today - index * 24 * 60 * 60 * 1000;
|
||||
return `${new Date(dtimestamp).getMonth() + 1}.${new Date(
|
||||
dtimestamp
|
||||
).getDate()}`;
|
||||
if (period == "week") {
|
||||
const dtimestamp = today - index * 24 * 60 * 60 * 1000;
|
||||
return `${new Date(dtimestamp).getMonth() + 1}.${new Date(
|
||||
dtimestamp
|
||||
).getDate()}`;
|
||||
} else if (period == "month") {
|
||||
return `${currentMonth}.${days - index}`;
|
||||
} else {
|
||||
return `${currentYear}.${12 - index}`;
|
||||
}
|
||||
})
|
||||
.reverse(),
|
||||
axisLabel: {
|
||||
|
||||
@@ -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 { lunarYear } from "../../../../utils/energeChartOption";
|
||||
|
||||
function NatGas(props) {
|
||||
const elecTrend = useSelector((state) => state.energy.trend.natGas1);
|
||||
@@ -66,9 +67,19 @@ function NatGas(props) {
|
||||
export default NatGas;
|
||||
|
||||
function getOptions(period, trend) {
|
||||
console.log("getOptions", period, trend);
|
||||
if (trend[period].length === 0) return null;
|
||||
// export default function getOptions(seriesData, name) {
|
||||
const today = new Date();
|
||||
const currentYear = today.getFullYear();
|
||||
const currentMonth = today.getMonth() + 1;
|
||||
let days = 30;
|
||||
if (period == "month") {
|
||||
if (currentMonth in [1, 3, 5, 7, 8, 10, 12]) {
|
||||
days = 31;
|
||||
} else if (currentMonth == 2) {
|
||||
days = lunarYear(currentYear) ? 29 : 28;
|
||||
}
|
||||
}
|
||||
const colors = [
|
||||
"#FFD160",
|
||||
"#12FFF5",
|
||||
@@ -99,14 +110,19 @@ function getOptions(period, trend) {
|
||||
},
|
||||
xAxis: {
|
||||
type: "category",
|
||||
data: Array(period == "week" ? 7 : period == "year" ? 12 : 30)
|
||||
data: Array(period == "week" ? 7 : period == "year" ? 12 : days)
|
||||
.fill(1)
|
||||
.map((_, index) => {
|
||||
const today = new Date();
|
||||
const dtimestamp = today - index * 24 * 60 * 60 * 1000;
|
||||
return `${new Date(dtimestamp).getMonth() + 1}.${new Date(
|
||||
dtimestamp
|
||||
).getDate()}`;
|
||||
if (period == "week") {
|
||||
const dtimestamp = today - index * 24 * 60 * 60 * 1000;
|
||||
return `${new Date(dtimestamp).getMonth() + 1}.${new Date(
|
||||
dtimestamp
|
||||
).getDate()}`;
|
||||
} else if (period == "month") {
|
||||
return `${currentMonth}.${days - index}`;
|
||||
} else {
|
||||
return `${currentYear}.${12 - index}`;
|
||||
}
|
||||
})
|
||||
.reverse(),
|
||||
axisLabel: {
|
||||
|
||||
Reference in New Issue
Block a user