<template>
|
<div id="wasteWaterRealChartBox" class="echarts-box">
|
<div class="tab-scroll">
|
<PublicDataStandard :dataStandard="dataStandard"></PublicDataStandard>
|
</div>
|
<div class="echarts-form">
|
<span class="demonstration">开始时间:</span>
|
<el-date-picker v-model="formData.startTime" value-format="yyyy-MM-dd HH:mm:ss" type="datetime" size="mini"></el-date-picker>
|
<span class="demonstration">结束时间:</span>
|
<el-date-picker v-model="formData.endTime" value-format="yyyy-MM-dd HH:mm:ss" type="datetime" size="mini"></el-date-picker>
|
<span class="demonstration">采样点数:</span>
|
<el-select class="selectBox" v-model="formData.region" placeholder="请选择" size="mini">
|
<el-option v-for="(item,index) in formData.regionList" :key="index" :label="item" :value="item"></el-option>
|
</el-select>
|
<el-button @click="querySearch()">查询</el-button>
|
<!-- <el-button>明细表</el-button>-->
|
</div>
|
<div class="echarts-chart">
|
<div ref="echarts"></div>
|
</div>
|
<span class="time-select">{{ formData.startTime }}—{{ formData.endTime }}</span>
|
</div>
|
</template>
|
|
<script>
|
|
import 'dayjs/locale/es'
|
import dayjs from 'dayjs'
|
|
import mapApi from '../../../api/mapApi'
|
import PublicDataStandard from '../PublicDataStandard'
|
|
export default {
|
name: 'WasteWaterRealChart',
|
components: {
|
PublicDataStandard
|
},
|
data () {
|
return {
|
// tab栏传递接收数据
|
dataStandard: [
|
{
|
current: {
|
name: '氮氧化物',
|
val: 29.93
|
},
|
standard: {
|
name: '标准',
|
val: 100
|
}
|
},
|
{
|
current: {
|
name: '二氧化硫',
|
val: 17.34
|
},
|
standard: {
|
name: '标准',
|
val: 50
|
}
|
},
|
{
|
current: {
|
name: '烟尘',
|
val: 6.93
|
},
|
standard: {
|
name: '标准',
|
val: 30
|
}
|
},
|
{
|
current: {
|
name: '废气流量',
|
val: 120
|
},
|
standard: {
|
name: '',
|
val: null
|
}
|
}],
|
// 表单数据绑定值
|
formData: {
|
region: '25',
|
regionList: [25, 50, 75, 100],
|
startTime: dayjs().subtract(3, 'minute').format('YYYY-MM-DD HH:mm:ss'),
|
endTime: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
},
|
// 数据分类处理存储列表
|
RealTimeDataList: [],
|
// 用于处理标准值
|
standardValues: null,
|
// 标准值列表
|
standardValuesList: [],
|
// 用于图表展示设置数组
|
nameList: [],
|
legendList: [],
|
ydatas: []
|
}
|
},
|
mounted () {
|
this.$nextTick(() => {
|
this.initEchartsData()
|
})
|
},
|
methods: {
|
// 查询搜索功能
|
querySearch () {
|
this.initEchartsData()
|
},
|
// 初始化数据请求
|
async initEchartsData () {
|
const data = {
|
$tagCodeList: 'TJIP45.y2h508CEMS01NOX,CTJIP45.y2h508CEMS01SO2,CTJIP45.y2h508CEMS01F,CTJIP45.y2h508CEMS01PM',
|
$startTime: this.formData.startTime,
|
$endTime: this.formData.endTime,
|
$step: 15
|
}
|
const result = (await mapApi.getDataItems(data)).data
|
// 数据按类别分组
|
this.pointsSet(result)
|
// 图标存储处理
|
this.legendSet()
|
// y轴data数据
|
this.yDataSet()
|
// 根据已有数据绘制图表
|
this.drawRealTimeDateChart()
|
},
|
// 接口数据按照 数据内分类别设置
|
pointsSet (d) {
|
// 数组数据置空
|
this.nameList = []
|
this.RealTimeDataList = []
|
|
let data = []
|
let datalist = []
|
|
for (let i = 0; i < d.length; i++) {
|
// 判断是否继续执行
|
if (d[i].ErrorMessage != null) {
|
continue
|
}
|
|
// temp 临时数据判断方法
|
const tempList = [
|
{
|
'TJIP45.lscl2tb552AISA11201B': 'COD',
|
'TJIP45.lscl2tbAIA-10505-1': '氨氮',
|
'TJIP45.lscl2tbAIA-10505-2': '总磷',
|
'TJIP45.lscl2tb552AI10710': '总氮',
|
'TJIP45.lscl2tb552AISA11202A': '废水流量'
|
}
|
]
|
// 指标 临时用于数据处理
|
const name = tempList[0][d[i].UnionTagCode]
|
|
// 判断市局类型进行分组 =>数组为空时
|
if (this.nameList.length === 0) {
|
this.nameList.push(name)
|
const newDate = new Date(d[i].ReadTime)
|
data = {
|
name: name,
|
value: [newDate, d[i].TagValue]
|
}
|
datalist = {
|
name: name,
|
data: [data]
|
}
|
this.RealTimeDataList.push(datalist)
|
} else if (this.nameList.indexOf(name) < 0) {
|
// 没有指标时
|
this.nameList.push(name)
|
const newDate = new Date(d[i].ReadTime)
|
data = {
|
name: name,
|
value: [newDate, d[i].TagValue]
|
}
|
datalist = {
|
name: name,
|
data: [data]
|
}
|
this.RealTimeDataList.push(datalist)
|
} else if (i === d.length - 1) {
|
// 循环到最后
|
if (this.nameList.indexOf(name) < 0) {
|
this.nameList.push(name)
|
const newDate = new Date(d[i].ReadTime)
|
data = {
|
name: name,
|
value: [newDate, d[i].TagValue]
|
}
|
datalist = {
|
name: name,
|
data: [data]
|
}
|
this.RealTimeDataList.push(datalist)
|
} else {
|
const newDate = new Date(d[i].ReadTime)
|
data = {
|
name: name,
|
value: [newDate, d[i].TagValue]
|
}
|
for (let k = 0; k < this.RealTimeDataList.length; k++) {
|
if (this.RealTimeDataList[k].name === name) {
|
this.RealTimeDataList[k].data.push(data)
|
}
|
}
|
}
|
} else {
|
const newDate = new Date(d[i].ReadTime)
|
data = {
|
name: name,
|
value: [newDate, d[i].TagValue]
|
}
|
for (let k = 0; k < this.RealTimeDataList.length; k++) {
|
if (this.RealTimeDataList[k].name === name) {
|
this.RealTimeDataList[k].data.push(data)
|
}
|
}
|
}
|
}
|
},
|
// legend类别图表展示设置数组
|
legendSet () {
|
this.legendList = []
|
let objTemp
|
for (let l = 0; l < this.nameList.length; l++) {
|
let obj
|
let IconUrl
|
if (this.nameList[l] === 'COD') {
|
IconUrl = 'image://../assets/imgs/legend/SO2.png'
|
} else if (this.nameList[l] === '氨氮') {
|
IconUrl = 'image://../assets/imgs/legend/NOX.png'
|
} else if (this.nameList[l] === '总磷') {
|
IconUrl = 'image://../assets/imgs/legend/YanChen.png'
|
} else if (this.nameList[l] === '总氮') {
|
IconUrl = 'image://../assets/imgs/legend/zongdan.png'
|
} else if (this.nameList[l] === '废水流量') {
|
IconUrl = 'image://../assets/imgs/legend/VOCs.png'
|
}
|
if (this.nameList[l] === '废水' || this.nameList[l] === '废水流量') { // 将废水流量排到数组最后
|
objTemp = {
|
name: this.nameList[l],
|
icon: IconUrl,
|
textStyle: {
|
color: '#ccc'
|
},
|
itemWidth: 20,
|
itemHeight: 5
|
}
|
} else {
|
obj = {
|
name: this.nameList[l],
|
icon: IconUrl,
|
textStyle: {
|
color: '#ccc'
|
},
|
itemWidth: 20,
|
itemHeight: 5
|
}
|
this.legendList.push(obj)
|
}
|
}
|
this.legendList.push(objTemp)
|
},
|
// yDataSet 数据处理
|
yDataSet () {
|
// 数组添加数据 置空
|
this.standardValuesList = []
|
this.ydatas = []
|
for (let j = 0; j < this.nameList.length; j++) {
|
let pointColor, lineColor
|
if (this.nameList[j] === 'COD') {
|
pointColor = 'red'
|
lineColor = '#ffff00'
|
} else if (this.nameList[j] === '氨氮') {
|
pointColor = 'red'
|
lineColor = '#00B0F0'
|
} else if (this.nameList[j] === '总磷') {
|
pointColor = 'red'
|
lineColor = '#f48183'
|
} else if (this.nameList[j] === '总氮') {
|
pointColor = 'red'
|
lineColor = '#e0ffff'
|
} else if (this.nameList[j] === '废水流量') {
|
pointColor = 'red'
|
lineColor = '#9ACD32'
|
}
|
|
// 临时数据
|
const BBZMAPPING = {
|
COD: 35,
|
氨氮: 30,
|
总磷: 0.3,
|
总氮: 15,
|
废水流量: 3
|
}
|
for (let m = 0; m < this.RealTimeDataList.length; m++) {
|
let stdValue = null
|
if (this.RealTimeDataList[m].name === this.nameList[j]) {
|
stdValue = BBZMAPPING[this.RealTimeDataList[m].name]
|
this.standardValues = {
|
name: this.nameList[j],
|
standardValue: stdValue
|
}
|
const yData = {
|
name: this.nameList[j],
|
data: this.RealTimeDataList[m].data,
|
pointColor: pointColor,
|
lineColor: lineColor,
|
standardValue: stdValue
|
}
|
this.standardValuesList.push(this.standardValues)
|
this.ydatas.push(yData)
|
}
|
}
|
}
|
},
|
// 根据处理好的数组进行echarts图标的渲染
|
drawRealTimeDateChart () {
|
this.myChart = this.$echarts.init(this.$refs.echarts)
|
this.myChart.clear()
|
|
// y轴侧边标题neme
|
const ySideName = '浓度(mg/m³)'
|
// 标准值列表
|
const standardValuesList = this.standardValuesList
|
|
// 应用于数据结果判断标准值
|
let standardValue
|
|
// series数据存储
|
const serLists = []
|
|
for (let i = 0; i < this.ydatas.length; i++) {
|
// 应用于数据处理
|
const pointColor = this.ydatas[i].pointColor
|
// 数据标准值
|
const bz = this.ydatas[i].standardValue
|
let seriesObj
|
|
if (bz) {
|
seriesObj = {
|
name: this.ydatas[i].name,
|
smooth: true,
|
type: 'line',
|
data: this.ydatas[i].data,
|
// borderColor: this.ydatas[i].pointColor,
|
borderColor: '#fff',
|
itemStyle: {
|
normal: {
|
color: function (c) {
|
for (let i = 0; i < standardValuesList.length; i++) {
|
if (standardValuesList[i].name === c.seriesName) {
|
standardValue = standardValuesList[i].standardValue
|
}
|
}
|
if (c.value[1] > standardValue) {
|
return pointColor
|
} else if (c.value[1] > standardValue * 0.7) {
|
return '#FFA500'
|
} else {
|
return '#33c95f'
|
}
|
},
|
lineStyle: {
|
color: this.ydatas[i].lineColor,
|
width: 2
|
},
|
label: { // 显示值
|
show: false
|
}
|
}
|
},
|
markLine: {
|
symbol: 'none',
|
data: [{
|
label: {
|
normal: {
|
position: 'end',
|
formatter: bz
|
}
|
},
|
name: '标准值',
|
yAxis: bz,
|
lineStyle: {
|
normal: {
|
color: function (c) {
|
for (let i = 0; i < standardValuesList.length; i++) {
|
if (standardValuesList[i].name === c.seriesName) {
|
standardValue = standardValuesList[i].standardValue
|
}
|
}
|
if (c.value[1] > standardValue) {
|
return pointColor
|
} else if (c.value[1] > standardValue * 0.7) {
|
return '#FFA500'
|
} else {
|
return '#33c95f'
|
}
|
}
|
}
|
}
|
}]
|
}
|
}
|
} else {
|
seriesObj = {
|
name: this.ydatas[i].name,
|
symbol: 'circle',
|
symbolSize: 10,
|
smooth: false,
|
yAxisIndex: 1,
|
// borderColor:'black',
|
type: 'line',
|
data: this.ydatas[i].data,
|
itemStyle: {
|
normal: {
|
color: function (c) {
|
for (let i = 0; i < standardValuesList.length; i++) {
|
if (standardValuesList[i].name === c.seriesName) {
|
standardValue = standardValuesList[i].standardValue
|
}
|
}
|
if (c.value[1] > standardValue) {
|
return pointColor
|
} else if (c.value[1] > standardValue * 0.9) {
|
return '#FFA500'
|
} else {
|
return '#33c95f'
|
}
|
},
|
lineStyle: { // 折线的颜色
|
color: this.ydatas[i].lineColor,
|
width: 2
|
},
|
label: { // 显示值
|
show: false
|
}
|
}
|
}
|
}
|
}
|
if (this.ydatas[i].name === '废水流量' || this.ydatas[i].name === '废水') {
|
seriesObj.yAxisIndex = 1
|
}
|
serLists.push(seriesObj)
|
}
|
const dataUnit = '流量(m³/h)'
|
// echarts图表option数据
|
const options = {
|
tooltip: {
|
trigger: 'axis',
|
axisPointer: {
|
type: 'cross',
|
label: {
|
color: '#1a4245'
|
}
|
},
|
formatter: function (params) {
|
let s = params[0].name + '<br />'
|
for (let i = 0; i < params.length; i++) {
|
const seriesName = params[i].seriesName
|
// 值
|
const value = params[i].value[1]
|
|
// const valueFliter = formatter(value)
|
const valueFliter = parseFloat(value).toFixed(2)
|
|
let maker = params[i].marker
|
let colo = ''
|
switch (seriesName) {
|
case 'COD':
|
colo = '#ffff00'
|
break
|
case '氨氮':
|
colo = '#00B0F0'
|
break
|
case '总氮':
|
colo = '#e0ffff'
|
break
|
case '废水流量':
|
colo = '#9ACD32'
|
break
|
case '总磷':
|
colo = '#f48183'
|
break
|
default:
|
colo = ''
|
break
|
}
|
maker = '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:' + colo + ';"></span>'
|
s += maker + seriesName + ':' + valueFliter + '<br />'
|
}
|
return s
|
}
|
},
|
toolbox: {
|
show: false,
|
feature: {
|
saveAsImage: {}
|
}
|
},
|
grid: {
|
// 与绝对定位相似,top,left,right,bottom 设定是根据上级盒子宽高来计算
|
top: '20%',
|
left: '6%',
|
right: '6%',
|
bottom: '12%'
|
},
|
legend: {
|
data: this.legendList
|
},
|
dataZoom: [{
|
type: 'inside',
|
start: 0,
|
end: 100
|
}, {
|
start: 0,
|
end: 100,
|
show: false,
|
handleIcon: 'M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z',
|
handleSize: '80%',
|
handleStyle: {
|
color: '#fff',
|
shadowBlur: 3,
|
shadowColor: 'rgba(0, 0, 0, 0.6)',
|
shadowOffsetX: 2,
|
shadowOffsetY: 2
|
}
|
}],
|
xAxis: {
|
type: 'time',
|
boundaryGap: false,
|
axisLabel: {
|
// rotate: 30,
|
margin: 6,
|
interval: 0,
|
textStyle: {
|
color: '#fff'
|
}
|
},
|
splitLine: {
|
show: true,
|
lineStyle: {
|
type: 'dashed'
|
}
|
},
|
axisTick: { // x 轴刻度显示
|
show: false
|
},
|
axisLine: {
|
lineStyle: {
|
color: '#FFFFFF',
|
width: 1
|
}
|
}
|
},
|
yAxis: [{
|
type: 'value',
|
name: ySideName,
|
max: function (value) {
|
return parseInt(value.max + 3)
|
},
|
axisLabel: {
|
formatter: '{value}',
|
textStyle: {
|
color: '#fff'
|
}
|
},
|
axisPointer: {
|
snap: true
|
},
|
splitLine: {
|
show: false
|
},
|
axisLine: {
|
lineStyle: {
|
color: '#FFFFFF',
|
width: 1
|
}
|
}
|
}, {
|
type: 'value',
|
name: dataUnit,
|
axisLabel: {
|
formatter: '{value}',
|
textStyle: {
|
color: '#fff'
|
}
|
},
|
axisPointer: {
|
snap: true
|
},
|
splitLine: {
|
show: false
|
},
|
// inverse: true,
|
// nameLocation: 'start',
|
// max:500,
|
axisLine: {
|
lineStyle: {
|
color: '#FFFFFF',
|
width: 1
|
}
|
}
|
}],
|
series: serLists
|
}
|
this.myChart.setOption(options)
|
window.onresize = this.myChart.resize
|
}
|
}
|
}
|
</script>
|
|
<style lang="less">
|
#wasteWaterRealChartBox .echarts-form .el-input__inner {
|
background-color: rgba(0, 0, 0, 0);
|
height: .13rem;
|
border-color: #336fa4;
|
}
|
#wasteWaterRealChartBox .echarts-form{
|
margin-top: 1px
|
}
|
#wasteWaterRealChartBox .echarts-form .el-input__icon{
|
height: .13rem;
|
top: -.02rem;
|
right: -0.03rem;
|
position: absolute;
|
color: #00d0f9;
|
}
|
#wasteWaterRealChartBox .echarts-form .selectBox .el-input__icon:last-child{
|
top: .02rem;
|
}
|
#wasteWaterRealChartBox .echarts-form .selectBox .is-reverse{
|
top: -.02rem !important;
|
}
|
#wasteWaterRealChartBox .echarts-form .el-button{
|
background-color: rgba(0, 0, 0, 0);
|
height: .13rem;
|
}
|
</style>
|