From 52afe2d58776967da3a03b00d7f635fc6fd7d1a8 Mon Sep 17 00:00:00 2001
From: chenzeping <ChenZeping02609@163.com>
Date: 星期一, 26 四月 2021 15:42:21 +0800
Subject: [PATCH] 标准值颜色标准
---
src/components/BaseNav/WasteWater/WasteWaterRealChart.vue | 280 ++++++++++++++++++++++++++-----------------------------
1 files changed, 133 insertions(+), 147 deletions(-)
diff --git a/src/components/BaseNav/WasteWater/WasteWaterRealChart.vue b/src/components/BaseNav/WasteWater/WasteWaterRealChart.vue
index cf1c44f..8d6654b 100644
--- a/src/components/BaseNav/WasteWater/WasteWaterRealChart.vue
+++ b/src/components/BaseNav/WasteWater/WasteWaterRealChart.vue
@@ -18,8 +18,8 @@
type="datetime">
</el-date-picker>
<span class="demonstration">閲囨牱鐐规暟锛�</span>
- <el-select v-model="region" placeholder="璇烽�夋嫨" style="width: 80px">
- <el-option v-for="(item,index) in regionList" :key="index" :label="item" :value="item"></el-option>
+ <el-select v-model="formData.region" placeholder="璇烽�夋嫨" style="width: 80px">
+ <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>-->
@@ -45,7 +45,6 @@
},
data () {
return {
- a: '',
// tab鏍忎紶閫掓帴鏀舵暟鎹�
dataStandard: [
{
@@ -88,19 +87,22 @@
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')
},
- region: '25',
- regionList: [25, 50, 75, 100],
- datatype: 1,
+ // 鏁版嵁鍒嗙被澶勭悊瀛樺偍鍒楄〃
RealTimeDataList: [],
- bzz: null,
- bzzList: [],
+ // 鐢ㄤ簬澶勭悊鏍囧噯鍊�
+ standardValues: null,
+ // 鏍囧噯鍊煎垪琛�
+ standardValuesList: [],
+ // 鐢ㄤ簬鍥捐〃灞曠ず璁剧疆鏁扮粍
nameList: [],
- // legend绫诲埆鍥捐〃灞曠ず璁剧疆鏁扮粍
- lengList: [],
+ legendList: [],
ydatas: []
}
},
@@ -122,29 +124,31 @@
$endTime: this.formData.endTime,
$step: 15
}
- // console.log(data)
const result = (await mapApi.getDataItems(data)).data
// 鏁版嵁鎸夌被鍒垎缁�
this.pointsSet(result)
// 鍥炬爣瀛樺偍澶勭悊
this.legendSet()
- // ydata鏁版嵁
+ // y杞磀ata鏁版嵁
this.yDataSet()
// 鏍规嵁宸叉湁鏁版嵁缁樺埗鍥捐〃
this.drawRealTimeDateChart()
},
// 鎺ュ彛鏁版嵁鎸夌収 鏁版嵁鍐呭垎绫诲埆璁剧疆
pointsSet (d) {
- let data = []
- let datalist = []
+ // 鏁扮粍鏁版嵁缃┖
this.nameList = []
this.RealTimeDataList = []
+
+ let data = []
+ let datalist = []
+
for (let i = 0; i < d.length; i++) {
- // this.RealTimeDataList = []
// 鍒ゆ柇鏄惁缁х画鎵ц
if (d[i].ErrorMessage != null) {
continue
}
+
// temp 涓存椂鏁版嵁鍒ゆ柇鏂规硶
const tempList = [
{
@@ -155,13 +159,12 @@
'TJIP45.lscl2tb552AISA11202A': '搴熸按娴侀噺'
}
]
- // 鎸囨爣
+ // 鎸囨爣 涓存椂鐢ㄤ簬鏁版嵁澶勭悊
const name = tempList[0][d[i].UnionTagCode]
- // 鍒ゆ柇甯傚眬绫诲瀷杩涜鍒嗙粍
+
+ // 鍒ゆ柇甯傚眬绫诲瀷杩涜鍒嗙粍 =>鏁扮粍涓虹┖鏃�
if (this.nameList.length === 0) {
- // 鏁扮粍涓虹┖鏃�
this.nameList.push(name)
- // todo 鐢╠ayjs
const newDate = new Date(d[i].ReadTime)
data = {
name: name,
@@ -171,7 +174,6 @@
name: name,
data: [data]
}
- // console.log('1111111')
this.RealTimeDataList.push(datalist)
} else if (this.nameList.indexOf(name) < 0) {
// 娌℃湁鎸囨爣鏃�
@@ -185,7 +187,6 @@
name: name,
data: [data]
}
- // console.log('222222222')
this.RealTimeDataList.push(datalist)
} else if (i === d.length - 1) {
// 寰幆鍒版渶鍚�
@@ -200,7 +201,6 @@
name: name,
data: [data]
}
- // console.log('3333333')
this.RealTimeDataList.push(datalist)
} else {
const newDate = new Date(d[i].ReadTime)
@@ -208,7 +208,6 @@
name: name,
value: [newDate, d[i].TagValue]
}
- // console.log('444444')
for (let k = 0; k < this.RealTimeDataList.length; k++) {
if (this.RealTimeDataList[k].name === name) {
this.RealTimeDataList[k].data.push(data)
@@ -228,11 +227,10 @@
}
}
}
- // console.log(this.RealTimeDataList)
},
// legend绫诲埆鍥捐〃灞曠ず璁剧疆鏁扮粍
legendSet () {
- this.lengList = []
+ this.legendList = []
let objTemp
for (let l = 0; l < this.nameList.length; l++) {
let obj
@@ -268,34 +266,34 @@
itemWidth: 20,
itemHeight: 5
}
- this.lengList.push(obj)
+ this.legendList.push(obj)
}
}
- this.lengList.push(objTemp)
+ this.legendList.push(objTemp)
},
// yDataSet 鏁版嵁澶勭悊
yDataSet () {
- this.bzzList = []
+ // 鏁扮粍娣诲姞鏁版嵁 缃┖
+ this.standardValuesList = []
this.ydatas = []
for (let j = 0; j < this.nameList.length; j++) {
- let zdcbcolor, zxcolor
+ let pointColor, lineColor
if (this.nameList[j] === 'COD') {
- zdcbcolor = 'red'
- zxcolor = '#ffff00'
+ pointColor = 'red'
+ lineColor = '#ffff00'
} else if (this.nameList[j] === '姘ㄦ爱') {
- zdcbcolor = 'red'
- zxcolor = '#00B0F0'
+ pointColor = 'red'
+ lineColor = '#00B0F0'
} else if (this.nameList[j] === '鎬荤7') {
- zdcbcolor = 'red'
- zxcolor = '#f48183'
+ pointColor = 'red'
+ lineColor = '#f48183'
} else if (this.nameList[j] === '鎬绘爱') {
- zdcbcolor = 'red'
- zxcolor = '#e0ffff'
+ pointColor = 'red'
+ lineColor = '#e0ffff'
} else if (this.nameList[j] === '搴熸按娴侀噺') {
- zdcbcolor = 'red'
- zxcolor = '#9ACD32'
+ pointColor = 'red'
+ lineColor = '#9ACD32'
}
- let ydata
// 涓存椂鏁版嵁
const BBZMAPPING = {
@@ -308,26 +306,20 @@
for (let m = 0; m < this.RealTimeDataList.length; m++) {
let stdValue = null
if (this.RealTimeDataList[m].name === this.nameList[j]) {
- for (const p in BBZMAPPING) {
- // console.log('p' + p)
- this.a = p
- stdValue = BBZMAPPING[this.RealTimeDataList[m].name]
- }
- // console.log(stdValue)
- this.bzz = {
+ stdValue = BBZMAPPING[this.RealTimeDataList[m].name]
+ this.standardValues = {
name: this.nameList[j],
- bzhui: stdValue
+ standardValue: stdValue
}
- ydata = {
+ const yData = {
name: this.nameList[j],
data: this.RealTimeDataList[m].data,
- zdcbcolor: zdcbcolor,
- zxcolor: zxcolor,
- bzz: stdValue
+ pointColor: pointColor,
+ lineColor: lineColor,
+ standardValue: stdValue
}
- // console.log(stdValue)
- this.bzzList.push(this.bzz)
- this.ydatas.push(ydata)
+ this.standardValuesList.push(this.standardValues)
+ this.ydatas.push(yData)
}
}
}
@@ -337,53 +329,58 @@
this.myChart = this.$echarts.init(this.$refs.echarts)
this.myChart.clear()
- const legend = this.lengList
- const yname = '娴撳害(mg/m鲁)'
- const bzzList = this.bzzList
+ // y杞翠晶杈规爣棰榥eme
+ const ySideName = '娴撳害(mg/m鲁)'
+ // 鏍囧噯鍊煎垪琛�
+ const standardValuesList = this.standardValuesList
+ // 搴旂敤浜庢暟鎹粨鏋滃垽鏂爣鍑嗗��
+ let standardValue
+
+ // series鏁版嵁瀛樺偍
const serLists = []
for (let i = 0; i < this.ydatas.length; i++) {
- const zdcbcolor = this.ydatas[i].zdcbcolor
- const bz = this.ydatas[i].bzz
- // console.log(bz)
- let obj
+ // 搴旂敤浜庢暟鎹鐞�
+ const pointColor = this.ydatas[i].pointColor
+ // 鏁版嵁鏍囧噯鍊�
+ const bz = this.ydatas[i].standardValue
+ let seriesObj
+
if (bz) {
- obj = {
+ seriesObj = {
name: this.ydatas[i].name,
- // symbol:'circle', // 鎶樼偣褰㈢姸
- // symbolSize: 3, //澶у皬
- smooth: true, // 鐩寸嚎 锛宼rue 涓烘洸绾�
+ smooth: true,
+ type: 'line',
+ data: this.ydatas[i].data,
+ // borderColor: this.ydatas[i].pointColor,
+ borderColor: '#fff',
itemStyle: {
normal: {
- color: function (c) { // 鏍规嵁value 鏄剧ず涓嶅悓鐨勬姌鐐归鑹�
- let biaozhuiz
- for (let i = 0; i < bzzList.length; i++) {
- if (bzzList[i].name === c.seriesName) {
- biaozhuiz = bzzList[i].bzhui
+ 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] > biaozhuiz) {
- return zdcbcolor
- } else if (c.value[1] > biaozhuiz * 0.9) {
+ 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].zxcolor,
+ lineStyle: {
+ color: this.ydatas[i].lineColor,
width: 2
},
- // borderColor:'black', //鎶樼偣杈规鐨勯鑹�
label: { // 鏄剧ず鍊�
show: false
}
}
},
- type: 'line',
- data: this.ydatas[i].data,
- markLine: { // 骞冲潎鍊� 锛� 鍜� 鎸囨爣涓婇檺
+ markLine: {
symbol: 'none',
data: [{
label: {
@@ -396,16 +393,15 @@
yAxis: bz,
lineStyle: {
normal: {
- color: function (c) { // 鏍规嵁value 鏄剧ず涓嶅悓鐨勬姌鐐归鑹�
- let biaozhuiz
- for (let i = 0; i < bzzList.length; i++) {
- if (bzzList[i].name === c.seriesName) {
- biaozhuiz = bzzList[i].bzhui
+ 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] > biaozhuiz) {
- return zdcbcolor
- } else if (c.value[1] > biaozhuiz * 0.9) {
+ if (c.value[1] > standardValue) {
+ return pointColor
+ } else if (c.value[1] > standardValue * 0.7) {
return '#FFA500'
} else {
return '#33c95f'
@@ -413,62 +409,55 @@
}
}
}
- }
- ]
+ }]
}
}
} else {
- obj = {
+ seriesObj = {
name: this.ydatas[i].name,
- symbol: 'circle', // 鎶樼偣褰㈢姸
- symbolSize: 10, // 澶у皬
- smooth: false, // 鐩寸嚎 锛宼rue 涓烘洸绾�
+ symbol: 'circle',
+ symbolSize: 10,
+ smooth: false,
yAxisIndex: 1,
- // itemStyle: {
- // normal: {
- // color: function (c) { // 鏍规嵁value 鏄剧ず涓嶅悓鐨勬姌鐐归鑹�
- // for (let i = 0; i < this.bzzList.length; i++) {
- // let biaozhuizs
- // if (this.bzzList[i].name === c.seriesName) {
- // biaozhuizs = this.bzzList[i].bzhui
- // }
- // console.log(biaozhuizs)
- // }
- // if (c.value[1] > 9) {
- // return zdcbcolor
- // } else {
- // return '#33c95f'
- // }
- // },
- // lineStyle: { // 鎶樼嚎鐨勯鑹�
- // color: this.ydatas[i].zxcolor,
- // width: 5
- // },
- // borderColor: 'black', // 鎶樼偣杈规鐨勯鑹�
- // label: { // 鏄剧ず鍊�
- // show: false
- // }
- // }
- // },
+ // borderColor:'black',
type: 'line',
- data: this.ydatas[i].data
+ 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 === '搴熸皵') {
- obj.yAxisIndex = 1
+ if (this.ydatas[i].name === '搴熸按娴侀噺' || this.ydatas[i].name === '搴熸按') {
+ seriesObj.yAxisIndex = 1
}
- serLists.push(obj)
+ serLists.push(seriesObj)
}
- // console.log(serLists)
- let dataUnit = ''
- if (this.datatype === 1) {
- dataUnit = '娴侀噺(m鲁/d)'
- } else {
- dataUnit = '娴侀噺(m鲁/h)'
- }
+ const dataUnit = '娴侀噺(m鲁/h)'
// echarts鍥捐〃option鏁版嵁
const options = {
- tooltip: { // 鎻愮ず妗�
+ tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross',
@@ -479,8 +468,6 @@
formatter: function (params) {
let s = params[0].name + '<br />'
for (let i = 0; i < params.length; i++) {
- // let name = params[i].name
- // 鍥捐〃title鍚嶇О
const seriesName = params[i].seriesName
// 鍊�
const value = params[i].value[1]
@@ -516,18 +503,18 @@
return s
}
},
- toolbox: { // 鎵撳嵃绛夊伐鍏�
+ toolbox: {
show: false,
feature: {
saveAsImage: {}
}
},
- grid: { // 缃戞牸
+ grid: {
top: '20%',
left: '15%'
},
legend: {
- data: legend
+ data: this.legendList
},
dataZoom: [{
type: 'inside',
@@ -547,10 +534,10 @@
shadowOffsetY: 2
}
}],
- xAxis: { // x 杞磋缃�
+ xAxis: {
type: 'time',
boundaryGap: false,
- axisLabel: { // x杞村叏閮ㄦ樉绀�
+ axisLabel: {
// rotate: 30,
margin: 6,
interval: 0,
@@ -558,7 +545,7 @@
color: '#fff'
}
},
- splitLine: { // 缃戞牸鍨傜洿绾夸负 铏氱嚎
+ splitLine: {
show: true,
lineStyle: {
type: 'dashed'
@@ -570,14 +557,13 @@
axisLine: {
lineStyle: {
color: '#FFFFFF',
- width: 1// 杩欓噷鏄负浜嗙獊鍑烘樉绀哄姞涓婄殑
+ width: 1
}
}
- // data: xdata
},
yAxis: [{
type: 'value',
- name: yname,
+ name: ySideName,
max: function (value) {
return parseInt(value.max + 3)
},
@@ -592,11 +578,11 @@
},
splitLine: {
show: false
- }, // y杞� 缃戞牸绾夸笉鏄剧ず,
+ },
axisLine: {
lineStyle: {
color: '#FFFFFF',
- width: 1// 杩欓噷鏄负浜嗙獊鍑烘樉绀哄姞涓婄殑
+ width: 1
}
}
}, {
@@ -613,14 +599,14 @@
},
splitLine: {
show: false
- }, // y杞� 缃戞牸绾夸笉鏄剧ず,
+ },
// inverse: true,
// nameLocation: 'start',
// max:500,
axisLine: {
lineStyle: {
color: '#FFFFFF',
- width: 1// 杩欓噷鏄负浜嗙獊鍑烘樉绀哄姞涓婄殑
+ width: 1
}
}
}],
--
Gitblit v1.8.0