mcfxkh-Web/src/views/Home/InfoDlg/YbcgDlg/chart.js

308 lines
5.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import React, { useMemo } from 'react';
import echarts from 'echarts/lib/echarts';
import ReactEcharts from 'echarts-for-react';
const pallete = [
['#177ab3', '#51c3e7'],
['#9976dc', '#c792ee'],
['#94a1eb', '#a7caf8'],
['#7ae5c3', '#c9f4ea'],
['#c7dca5', '#f5fcd5'],
['#7988d9', '#9dc6f1'],
['#d9ed8f', '#d3f89b'],
];
const palleteLen = pallete.length;
const AreaDrpChart = () => {
const x = [
"2025-06-02 15:00:00",
"2025-06-02 16:00:00",
"2025-06-02 17:00:00",
"2025-06-02 18:00:00",
"2025-06-02 19:00:00",
"2025-06-02 20:00:00",
"2025-06-02 21:00:00",
"2025-06-03 01:00:00",
"2025-06-03 02:00:00",
"2025-06-03 04:00:00",
"2025-06-03 06:00:00",
"2025-06-03 08:00:00",
"2025-06-03 10:00:00",
"2025-06-03 12:00:00",
"2025-06-03 13:00:00",
"2025-06-03 14:00:00"
]
const y = [
24.05,
22.04,
21.03,
24.03,
25.02,
25.02,
27.02,
28,
27.99,
29.99,
27.97,
28.97,
29.97,
28.98,
27.97,
29.97
]
const y1 = [
23.05,
24.04,
24.03,
24.03,
23.02,
23.02,
23.02,
24,
23.99,
23.99,
23.97,
23.97,
23.97,
23.98,
23.97,
23.97
]
const y2 = [
23.05,
23.24,
23.53,
23.43,
23.02,
23.22,
23.02,
23,
23.19,
23.29,
23.57,
23.57,
23.67,
23.78,
23.87,
23.67
]
const y3 = [
14.05,
12.24,
13.53,
13.43,
14.02,
13.22,
14.02,
15,
16.19,
15.29,
17.57,
18.57,
18.67,
19.78,
18.87,
18.67
]
var option = {
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow',
label: {
show: false
}
},
// valueFormatter: (value) => value + ' 万m³'
},
grid: {
top: 42,
left: 50,
right: 40,
bottom: 27,
},
legend: {
data: ['水文预报','全局优先', '兴利优先','实时监测'],
top: '8',
icon:'circle',
left: 'center',
itemWidth: 11,//11,
itemHeight: 11,//11,
textStyle: {
color: '#B9BFC9',
fontSize: 12,//12
}
},
xAxis: [
{
type: 'category',
data: x,
splitLine: {
show: true, //隐藏X轴轴线
lineStyle: {
color: 'rgba(255,255,255,0.2)',
width: 0
}
},
axisLabel: {
show: true,
textStyle: {
color: '#B9BFC9' //X轴文字颜色
},
formatter: val => val.substr('2020-10-14 '.length, 5),
// rotate: 20, // 角度值Number
fontSize: 10,//10
},
axisLine: {
show: true, //隐藏X轴轴线
lineStyle: {
color: 'rgba(255,255,255,0.2)',
width: 0
}
},
axisTick: {
show: true,
}
}
],
yAxis: [
{
type: 'value',
position: 'left',
name: '流量',
nameTextStyle: {
color: '#B9BFC9',
fontSize: 10,//10,
padding: [0, 0, 0, -40],//[0, 0, 0, -30]//控制y轴标题位置
},
nameGap: 17,
splitLine: {
show: true,
lineStyle: {
width: 1,
color: 'rgba(255,255,255,0.2)'
}
},
axisLabel: {
show: true,
textStyle: {
color: '#B9BFC9',
fontSize: 11,//11
}
},
axisLine: {
show: false
},
axisTick: {
show: false,
},
min: 5,
// max: 135,
}
],
series: [
{
name: '水文预报',
type: 'line',
barWidth: 10,
data: y,
showSymbol: false,
itemStyle: {
normal: {
color: '#32e1b5'
},
},
// label: {
// show: true,
// position: 'top',
// color: '#bbb',
// fontSize: 12,
// textShadowBlur: 4,
// textShadowColor: '#6ab',
// },
},
{
name: '全局优先',
type: 'line',
barWidth: 10,
showSymbol: false,
data: y1,
itemStyle: {
normal: {
color: '#f19932'
},
},
// label: {
// show: true,
// position: 'top',
// color: '#bbb',
// fontSize: 12,
// textShadowBlur: 4,
// textShadowColor: '#6ab',
// },
},
{
name: '兴利优先',
type: 'line',
barWidth: 10,
showSymbol: false,
data: y2,
itemStyle: {
normal: {
color: '#e1554e'
},
},
// label: {
// show: true,
// position: 'top',
// color: '#bbb',
// fontSize: 12,
// textShadowBlur: 4,
// textShadowColor: '#6ab',
// },
},
{
name: '实时监测',
type: 'line',
barWidth: 10,
showSymbol: false,
data: y3,
itemStyle: {
normal: {
color: '#e1554e'
},
},
// label: {
// show: true,
// position: 'top',
// color: '#bbb',
// fontSize: 12,
// textShadowBlur: 4,
// textShadowColor: '#6ab',
// },
}
]
};
return (
<ReactEcharts
option={option}
style={{ height: '99%', width: '100%' }}
/>
)
}
export default React.memo(AreaDrpChart);