Browse Source

refactor: 统计图表添加盐分温度,修改环温环湿为全称,去掉cross Y轴的值

master
wally 4 years ago
parent
commit
f57da51c31
  1. 75
      src/config/chart.js
  2. 4
      src/utils/statistical.js

75
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,
},
];

4
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: [

Loading…
Cancel
Save