From f57da51c317846dcd8e88656de0ee3a72e559b1e Mon Sep 17 00:00:00 2001 From: wally <18603454788@163.com> Date: Wed, 17 Nov 2021 16:44:18 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=BB=9F=E8=AE=A1=E5=9B=BE?= =?UTF-8?q?=E8=A1=A8=E6=B7=BB=E5=8A=A0=E7=9B=90=E5=88=86=E6=B8=A9=E5=BA=A6?= =?UTF-8?q?,=E4=BF=AE=E6=94=B9=E7=8E=AF=E6=B8=A9=E7=8E=AF=E6=B9=BF?= =?UTF-8?q?=E4=B8=BA=E5=85=A8=E7=A7=B0,=E5=8E=BB=E6=8E=89cross=20Y?= =?UTF-8?q?=E8=BD=B4=E7=9A=84=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/chart.js | 75 +++++++++++++++++++++++++++++++--------- src/utils/statistical.js | 4 +-- 2 files changed, 60 insertions(+), 19 deletions(-) diff --git a/src/config/chart.js b/src/config/chart.js index c2b25e2..299b7c7 100644 --- a/src/config/chart.js +++ b/src/config/chart.js @@ -1,7 +1,19 @@ /* eslint-disable max-len */ -export const colors = ['#5470C6', '#91CC75', '#EE6666', '#5470C6', '#91CC75', '#EE6666', '#5470C6', '#91CC75']; +export const colors = ['#5470C6', '#91CC75', '#EE6666', '#5470C6', '#91CC75', '#EE6666', '#5470C6', '#91CC75', '#5470C6']; -// 默认legend +export const legendData = [ + 'SO2(ppb)', + '盐分阻抗(Ω)', + '盐分温度(℃)', + '环境温度(℃)', + '环境湿度(RH%)', + '锌腐蚀电流(nA)', + '铜腐蚀电流(nA)', + '铝腐蚀电流(nA)', + '钢腐蚀电流(nA)', +]; + +// 默认legend select export const defaultSelectedLegend = { '钢腐蚀电流(nA)': true, '铜腐蚀电流(nA)': true, @@ -9,8 +21,9 @@ export const defaultSelectedLegend = { '锌腐蚀电流(nA)': true, 'SO2(ppb)': false, '盐分阻抗(Ω)': false, - '环温(℃)': false, - '环湿(RH%)': false, + '盐分温度(℃)': false, + '环境温度(℃)': false, + '环境湿度(RH%)': false, }; // y轴定义 @@ -25,6 +38,7 @@ export const yAxisData = [ lineStyle: { color: colors[0] }, }, axisLabel: { formatter: '{value}ppb' }, + axisPointer: { show: false }, }, { type: 'value', @@ -37,10 +51,12 @@ export const yAxisData = [ lineStyle: { color: colors[1] }, }, axisLabel: { formatter: '{value}Ω' }, + axisPointer: { show: false }, }, + { type: 'value', - name: '环温(℃)', + name: '环境温度(℃)', show: false, position: 'left', offset: 135, @@ -49,10 +65,11 @@ export const yAxisData = [ lineStyle: { color: colors[2] }, }, axisLabel: { formatter: '{value}°C' }, + axisPointer: { show: false }, }, { type: 'value', - name: '环湿(RH%)', + name: '环境湿度(RH%)', show: false, position: 'left', offset: 200, @@ -61,6 +78,20 @@ export const yAxisData = [ lineStyle: { color: colors[3] }, }, axisLabel: { formatter: '{value}RH%' }, + axisPointer: { show: false }, + }, + { + type: 'value', + name: '盐分温度(℃)', + show: false, + position: 'left', + offset: 270, + axisLine: { + show: true, + lineStyle: { color: colors[4] }, + }, + axisLabel: { formatter: '{value}Ω' }, + axisPointer: { show: false }, }, { type: 'value', @@ -68,9 +99,10 @@ export const yAxisData = [ position: 'right', axisLine: { show: true, - lineStyle: { color: colors[4] }, + lineStyle: { color: colors[5] }, }, axisLabel: { formatter: '{value}' }, + axisPointer: { show: false }, }, { type: 'value', @@ -79,9 +111,10 @@ export const yAxisData = [ position: 'right', axisLine: { show: true, - lineStyle: { color: colors[5] }, + lineStyle: { color: colors[6] }, }, axisLabel: { formatter: '{value}' }, + axisPointer: { show: false }, }, { type: 'value', @@ -90,9 +123,10 @@ export const yAxisData = [ position: 'right', axisLine: { show: true, - lineStyle: { color: colors[6] }, + lineStyle: { color: colors[7] }, }, axisLabel: { formatter: '{value}' }, + axisPointer: { show: false }, }, { type: 'value', @@ -101,9 +135,10 @@ export const yAxisData = [ position: 'right', axisLine: { show: true, - lineStyle: { color: colors[7] }, + lineStyle: { color: colors[8] }, }, axisLabel: { formatter: '{value}' }, + axisPointer: { show: false }, }, ]; @@ -123,42 +158,48 @@ export function generateDefaultSeries(data) { name: '盐分阻抗(Ω)', type: 'line', yAxisIndex: 1, - data: data.salt, + data: data.saltR, }, { - name: '环温(℃)', + name: '环境温度(℃)', type: 'line', yAxisIndex: 2, data: data.environmentTemperature, }, { - name: '环湿(RH%)', + name: '环境湿度(RH%)', type: 'line', yAxisIndex: 3, data: data.environmentHumidity, }, { - name: '锌腐蚀电流(nA)', + name: '盐分温度(℃)', type: 'line', yAxisIndex: 4, + data: data.saltT, + }, + { + name: '锌腐蚀电流(nA)', + type: 'line', + yAxisIndex: 5, data: data.corrosionXIN, }, { name: '铜腐蚀电流(nA)', type: 'line', - yAxisIndex: 5, + yAxisIndex: 6, data: data.corrosionTONG, }, { name: '铝腐蚀电流(nA)', type: 'line', - yAxisIndex: 6, + yAxisIndex: 7, data: data.corrosionLV, }, { name: '钢腐蚀电流(nA)', type: 'line', - yAxisIndex: 7, + yAxisIndex: 8, data: data.corrosionGANG, }, ]; diff --git a/src/utils/statistical.js b/src/utils/statistical.js index e6a6a39..65d9eda 100644 --- a/src/utils/statistical.js +++ b/src/utils/statistical.js @@ -1,7 +1,7 @@ /* eslint-disable max-len,object-curly-newline */ import dayjs from 'dayjs'; import max from 'lodash/max'; -import { colors, defaultSelectedLegend, generateDefaultSeries, yAxisData } from '@/config/chart'; +import { colors, defaultSelectedLegend, generateDefaultSeries, legendData, yAxisData } from '@/config/chart'; /** * 生成chart所需参数 @@ -130,7 +130,7 @@ export function generateChartOption(rawData, selected = defaultSelectedLegend) { grid, legend: { selected, - data: ['SO2(ppb)', '盐分阻抗(Ω)', '环温(℃)', '环湿(RH%)', '锌腐蚀电流(nA)', '铜腐蚀电流(nA)', '铝腐蚀电流(nA)', '钢腐蚀电流(nA)'], + data: legendData, }, dataZoom: [{ type: 'inside' }, { type: 'slider' }], xAxis: [