32 lines
907 B
JavaScript
32 lines
907 B
JavaScript
import cls from "./index.module.css";
|
|
import ReactECharts from "echarts-for-react";
|
|
import getOptions from "./chart.config";
|
|
import { useSelector, useDispatch } from "react-redux";
|
|
|
|
function GasChart(props) {
|
|
const { dataSource } = props;
|
|
const hisState = useSelector((state) => state.natGas.history);
|
|
const dataName = dataSource == "gas-i" ? "gasIHistory" : "gasIIHistory";
|
|
|
|
const seriesData = hisState?.[dataName]
|
|
? Object.keys(hisState?.[dataName])
|
|
.sort()
|
|
.map((key, index) => hisState?.[dataName][key])
|
|
: Array(dataSource == "gas-i" ? 8 : 4).fill(Array(7).fill(0));
|
|
|
|
return (
|
|
<div className={cls.gasChart}>
|
|
<ReactECharts
|
|
key={dataSource}
|
|
option={getOptions(
|
|
seriesData,
|
|
dataSource == "gas-i" ? "天然气I" : "天然气II"
|
|
)}
|
|
style={{ height: "100%" }}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default GasChart;
|