|
@ -43,13 +43,136 @@ function generateParams(data) { |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const yAxisData = [ |
|
|
|
|
|
{ |
|
|
|
|
|
type: 'value', |
|
|
|
|
|
name: 'SO2(ppb)', |
|
|
|
|
|
position: 'left', |
|
|
|
|
|
axisLine: { |
|
|
|
|
|
show: true, |
|
|
|
|
|
lineStyle: { color: colors[0] }, |
|
|
|
|
|
}, |
|
|
|
|
|
axisLabel: { formatter: '{value}ppb' }, |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
type: 'value', |
|
|
|
|
|
name: '盐分阻抗(Ω)', |
|
|
|
|
|
// min: 0,
|
|
|
|
|
|
// max: 250,
|
|
|
|
|
|
position: 'left', |
|
|
|
|
|
offset: 70, |
|
|
|
|
|
axisLine: { |
|
|
|
|
|
show: true, |
|
|
|
|
|
lineStyle: { color: colors[1] }, |
|
|
|
|
|
}, |
|
|
|
|
|
axisLabel: { formatter: '{value}Ω' }, |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
type: 'value', |
|
|
|
|
|
name: '环温(℃)', |
|
|
|
|
|
// min: 0,
|
|
|
|
|
|
// max: 25,
|
|
|
|
|
|
position: 'left', |
|
|
|
|
|
offset: 135, |
|
|
|
|
|
axisLine: { |
|
|
|
|
|
show: true, |
|
|
|
|
|
lineStyle: { color: colors[2] }, |
|
|
|
|
|
}, |
|
|
|
|
|
axisLabel: { formatter: '{value}°C' }, |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
type: 'value', |
|
|
|
|
|
name: '环湿(RH%)', |
|
|
|
|
|
// min: 0,
|
|
|
|
|
|
// max: 25,
|
|
|
|
|
|
position: 'left', |
|
|
|
|
|
offset: 200, |
|
|
|
|
|
axisLine: { |
|
|
|
|
|
show: true, |
|
|
|
|
|
lineStyle: { color: colors[3] }, |
|
|
|
|
|
}, |
|
|
|
|
|
axisLabel: { formatter: '{value}RH%' }, |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
type: 'value', |
|
|
|
|
|
name: '锌腐蚀电流(nA)', |
|
|
|
|
|
position: 'right', |
|
|
|
|
|
axisLine: { |
|
|
|
|
|
show: true, |
|
|
|
|
|
lineStyle: { color: colors[4] }, |
|
|
|
|
|
}, |
|
|
|
|
|
axisLabel: { formatter: '{value}' }, |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
type: 'value', |
|
|
|
|
|
name: '铜腐蚀电流(nA)', |
|
|
|
|
|
offset: 100, |
|
|
|
|
|
position: 'right', |
|
|
|
|
|
axisLine: { |
|
|
|
|
|
show: true, |
|
|
|
|
|
lineStyle: { color: colors[5] }, |
|
|
|
|
|
}, |
|
|
|
|
|
axisLabel: { formatter: '{value}' }, |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
type: 'value', |
|
|
|
|
|
name: '铝腐蚀电流(nA)', |
|
|
|
|
|
offset: 200, |
|
|
|
|
|
position: 'right', |
|
|
|
|
|
axisLine: { |
|
|
|
|
|
show: true, |
|
|
|
|
|
lineStyle: { color: colors[6] }, |
|
|
|
|
|
}, |
|
|
|
|
|
axisLabel: { formatter: '{value}' }, |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
type: 'value', |
|
|
|
|
|
name: '钢腐蚀电流(nA)', |
|
|
|
|
|
offset: 300, |
|
|
|
|
|
position: 'right', |
|
|
|
|
|
axisLine: { |
|
|
|
|
|
show: true, |
|
|
|
|
|
lineStyle: { color: colors[7] }, |
|
|
|
|
|
}, |
|
|
|
|
|
axisLabel: { formatter: '{value}' }, |
|
|
|
|
|
}, |
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 生产y轴内容 |
|
|
|
|
|
* @param {Object} selectedLegend |
|
|
|
|
|
* @returns {({axisLabel: {formatter: string}, axisLine: {lineStyle: {color: string}, show: boolean}, name: string, position: string, type: string}|{axisLabel: {formatter: string}, offset: number, axisLine: {lineStyle: {color: string}, show: boolean}, name: string, position: string, type: string}|{axisLabel: {formatter: string}, offset: number, axisLine: {lineStyle: {color: string}, show: boolean}, name: string, position: string, type: string}|{axisLabel: {formatter: string}, offset: number, axisLine: {lineStyle: {color: string}, show: boolean}, name: string, position: string, type: string}|{axisLabel: {formatter: string}, axisLine: {lineStyle: {color: string}, show: boolean}, name: string, position: string, type: string})[]} |
|
|
|
|
|
*/ |
|
|
|
|
|
export function generateYAxis(selectedLegend) { |
|
|
|
|
|
console.log(selectedLegend); |
|
|
|
|
|
return yAxisData.filter(item => selectedLegend[item.name]); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 生成初始状态的y轴 |
|
|
|
|
|
* @returns {({axisLabel: {formatter: string}, axisLine: {lineStyle: {color: string}, show: boolean}, name: string, position: string, type: string}|{axisLabel: {formatter: string}, offset: number, axisLine: {lineStyle: {color: string}, show: boolean}, name: string, position: string, type: string}|{axisLabel: {formatter: string}, offset: number, axisLine: {lineStyle: {color: string}, show: boolean}, name: string, position: string, type: string}|{axisLabel: {formatter: string}, offset: number, axisLine: {lineStyle: {color: string}, show: boolean}, name: string, position: string, type: string}|{axisLabel: {formatter: string}, axisLine: {lineStyle: {color: string}, show: boolean}, name: string, position: string, type: string})[]} |
|
|
|
|
|
*/ |
|
|
|
|
|
export function generateDefaultYAxis() { |
|
|
|
|
|
const selectedLegend = [ |
|
|
|
|
|
{ |
|
|
|
|
|
'钢腐蚀电流(nA)': true, |
|
|
|
|
|
'铜腐蚀电流(nA)': true, |
|
|
|
|
|
'铝腐蚀电流(nA)': true, |
|
|
|
|
|
'锌腐蚀电流(nA)': true, |
|
|
|
|
|
}, |
|
|
|
|
|
]; |
|
|
|
|
|
return yAxisData.filter(item => selectedLegend.find(selected => selected[item.name])); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 生成chart参数 |
|
|
* 生成chart参数 |
|
|
* @param {Object[]} rawData 返回段返回的data数据 |
|
|
* @param {Object[]} rawData 返回段返回的data数据 |
|
|
|
|
|
* @param {Object[]} yAxis |
|
|
* @returns {{yAxis: [{axisLabel: {formatter: string}, axisLine: {lineStyle: {color: string}, show: boolean}, name: string, position: string, type: string},{axisLabel: {formatter: string}, offset: number, axisLine: {lineStyle: {color: string}, show: boolean}, name: string, position: string, type: string},{axisLabel: {formatter: string}, axisLine: {lineStyle: {color: string}, show: boolean}, name: string, position: string, type: string},{axisLabel: {formatter: string}, axisLine: {lineStyle: {color: string}, show: boolean}, name: string, position: string, type: string},{axisLabel: {formatter: string}, axisLine: {lineStyle: {color: string}, show: boolean}, name: string, position: string, type: string},null,null,null], xAxis: [{data: *[], axisTick: {alignWithLabel: boolean}, type: string}], color: string[], grid: {right: string}, legend: {data: string[]}, series: [{data: *[], name: string, type: string},{data: *[], name: string, type: string, yAxisIndex: number},{data: *[], name: string, type: string, yAxisIndex: number},{data: *[], name: string, type: string, yAxisIndex: number},{data: *[], name: string, type: string, yAxisIndex: number},null,null,null], tooltip: {axisPointer: {type: string}, trigger: string}, toolbox: {feature: {saveAsImage: {show: boolean}, restore: {show: boolean}, dataView: {show: boolean, readOnly: boolean}}}}} |
|
|
* @returns {{yAxis: [{axisLabel: {formatter: string}, axisLine: {lineStyle: {color: string}, show: boolean}, name: string, position: string, type: string},{axisLabel: {formatter: string}, offset: number, axisLine: {lineStyle: {color: string}, show: boolean}, name: string, position: string, type: string},{axisLabel: {formatter: string}, axisLine: {lineStyle: {color: string}, show: boolean}, name: string, position: string, type: string},{axisLabel: {formatter: string}, axisLine: {lineStyle: {color: string}, show: boolean}, name: string, position: string, type: string},{axisLabel: {formatter: string}, axisLine: {lineStyle: {color: string}, show: boolean}, name: string, position: string, type: string},null,null,null], xAxis: [{data: *[], axisTick: {alignWithLabel: boolean}, type: string}], color: string[], grid: {right: string}, legend: {data: string[]}, series: [{data: *[], name: string, type: string},{data: *[], name: string, type: string, yAxisIndex: number},{data: *[], name: string, type: string, yAxisIndex: number},{data: *[], name: string, type: string, yAxisIndex: number},{data: *[], name: string, type: string, yAxisIndex: number},null,null,null], tooltip: {axisPointer: {type: string}, trigger: string}, toolbox: {feature: {saveAsImage: {show: boolean}, restore: {show: boolean}, dataView: {show: boolean, readOnly: boolean}}}}} |
|
|
*/ |
|
|
*/ |
|
|
// eslint-disable-next-line import/prefer-default-export
|
|
|
// eslint-disable-next-line import/prefer-default-export
|
|
|
export function generateChartOption(rawData) { |
|
|
export function generateChartOption(rawData, yAxis) { |
|
|
|
|
|
console.log(yAxis); |
|
|
const data = generateParams(rawData); |
|
|
const data = generateParams(rawData); |
|
|
const option = { |
|
|
const option = { |
|
|
color: colors, |
|
|
color: colors, |
|
@ -72,100 +195,7 @@ export function generateChartOption(rawData) { |
|
|
data: data.time, |
|
|
data: data.time, |
|
|
}, |
|
|
}, |
|
|
], |
|
|
], |
|
|
yAxis: [ |
|
|
yAxis: yAxisData, |
|
|
{ |
|
|
|
|
|
type: 'value', |
|
|
|
|
|
name: 'SO2(ppb)', |
|
|
|
|
|
position: 'left', |
|
|
|
|
|
axisLine: { |
|
|
|
|
|
show: true, |
|
|
|
|
|
lineStyle: { color: colors[0] }, |
|
|
|
|
|
}, |
|
|
|
|
|
axisLabel: { formatter: '{value}ppb' }, |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
type: 'value', |
|
|
|
|
|
name: '盐分阻抗(Ω)', |
|
|
|
|
|
// min: 0,
|
|
|
|
|
|
// max: 250,
|
|
|
|
|
|
position: 'left', |
|
|
|
|
|
offset: 70, |
|
|
|
|
|
axisLine: { |
|
|
|
|
|
show: true, |
|
|
|
|
|
lineStyle: { color: colors[1] }, |
|
|
|
|
|
}, |
|
|
|
|
|
axisLabel: { formatter: '{value}Ω' }, |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
type: 'value', |
|
|
|
|
|
name: '环温(℃)', |
|
|
|
|
|
// min: 0,
|
|
|
|
|
|
// max: 25,
|
|
|
|
|
|
position: 'left', |
|
|
|
|
|
offset: 135, |
|
|
|
|
|
axisLine: { |
|
|
|
|
|
show: true, |
|
|
|
|
|
lineStyle: { color: colors[2] }, |
|
|
|
|
|
}, |
|
|
|
|
|
axisLabel: { formatter: '{value}°C' }, |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
type: 'value', |
|
|
|
|
|
name: '环湿(RH%)', |
|
|
|
|
|
// min: 0,
|
|
|
|
|
|
// max: 25,
|
|
|
|
|
|
position: 'left', |
|
|
|
|
|
offset: 200, |
|
|
|
|
|
axisLine: { |
|
|
|
|
|
show: true, |
|
|
|
|
|
lineStyle: { color: colors[3] }, |
|
|
|
|
|
}, |
|
|
|
|
|
axisLabel: { formatter: '{value}RH%' }, |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
type: 'value', |
|
|
|
|
|
name: '锌腐蚀电流(nA)', |
|
|
|
|
|
position: 'right', |
|
|
|
|
|
axisLine: { |
|
|
|
|
|
show: true, |
|
|
|
|
|
lineStyle: { color: colors[4] }, |
|
|
|
|
|
}, |
|
|
|
|
|
axisLabel: { formatter: '{value}' }, |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
type: 'value', |
|
|
|
|
|
name: '铜腐蚀电流(nA)', |
|
|
|
|
|
offset: 100, |
|
|
|
|
|
position: 'right', |
|
|
|
|
|
axisLine: { |
|
|
|
|
|
show: true, |
|
|
|
|
|
lineStyle: { color: colors[5] }, |
|
|
|
|
|
}, |
|
|
|
|
|
axisLabel: { formatter: '{value}' }, |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
type: 'value', |
|
|
|
|
|
name: '铝腐蚀电流(nA)', |
|
|
|
|
|
offset: 200, |
|
|
|
|
|
position: 'right', |
|
|
|
|
|
axisLine: { |
|
|
|
|
|
show: true, |
|
|
|
|
|
lineStyle: { color: colors[6] }, |
|
|
|
|
|
}, |
|
|
|
|
|
axisLabel: { formatter: '{value}' }, |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
type: 'value', |
|
|
|
|
|
name: '钢腐蚀电流(nA)', |
|
|
|
|
|
offset: 300, |
|
|
|
|
|
position: 'right', |
|
|
|
|
|
axisLine: { |
|
|
|
|
|
show: true, |
|
|
|
|
|
lineStyle: { color: colors[7] }, |
|
|
|
|
|
}, |
|
|
|
|
|
axisLabel: { formatter: '{value}' }, |
|
|
|
|
|
}, |
|
|
|
|
|
], |
|
|
|
|
|
series: [ |
|
|
series: [ |
|
|
{ |
|
|
{ |
|
|
name: 'SO2(ppb)', |
|
|
name: 'SO2(ppb)', |
|
|