|
@ -43,36 +43,7 @@ function generateParams(data) { |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
const yAxisData = [ |
|
|
* 生成chart参数 |
|
|
|
|
|
* @param {Object[]} rawData 返回段返回的data数据 |
|
|
|
|
|
* @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
|
|
|
|
|
|
export function generateChartOption(rawData) { |
|
|
|
|
|
const data = generateParams(rawData); |
|
|
|
|
|
const option = { |
|
|
|
|
|
color: colors, |
|
|
|
|
|
tooltip: { |
|
|
|
|
|
trigger: 'axis', |
|
|
|
|
|
axisPointer: { type: 'cross' }, |
|
|
|
|
|
}, |
|
|
|
|
|
grid: { |
|
|
|
|
|
right: '30%', |
|
|
|
|
|
left: '20%', |
|
|
|
|
|
}, |
|
|
|
|
|
legend: { |
|
|
|
|
|
data: ['SO2(ppb)', '盐分阻抗(Ω)', '环温(℃)', '环湿(RH%)', '锌腐蚀电流(nA)', '铜腐蚀电流(nA)', '铝腐蚀电流(nA)', '钢腐蚀电流(nA)'], |
|
|
|
|
|
}, |
|
|
|
|
|
dataZoom: [{ type: 'inside' }, { type: 'slider' }], |
|
|
|
|
|
xAxis: [ |
|
|
|
|
|
{ |
|
|
|
|
|
type: 'category', |
|
|
|
|
|
axisTick: { alignWithLabel: true }, |
|
|
|
|
|
data: data.time, |
|
|
|
|
|
}, |
|
|
|
|
|
], |
|
|
|
|
|
yAxis: [ |
|
|
|
|
|
{ |
|
|
{ |
|
|
type: 'value', |
|
|
type: 'value', |
|
|
name: 'SO2(ppb)', |
|
|
name: 'SO2(ppb)', |
|
@ -165,7 +136,66 @@ export function generateChartOption(rawData) { |
|
|
}, |
|
|
}, |
|
|
axisLabel: { formatter: '{value}' }, |
|
|
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参数 |
|
|
|
|
|
* @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}}}}} |
|
|
|
|
|
*/ |
|
|
|
|
|
// eslint-disable-next-line import/prefer-default-export
|
|
|
|
|
|
export function generateChartOption(rawData, yAxis) { |
|
|
|
|
|
console.log(yAxis); |
|
|
|
|
|
const data = generateParams(rawData); |
|
|
|
|
|
const option = { |
|
|
|
|
|
color: colors, |
|
|
|
|
|
tooltip: { |
|
|
|
|
|
trigger: 'axis', |
|
|
|
|
|
axisPointer: { type: 'cross' }, |
|
|
|
|
|
}, |
|
|
|
|
|
grid: { |
|
|
|
|
|
right: '30%', |
|
|
|
|
|
left: '20%', |
|
|
|
|
|
}, |
|
|
|
|
|
legend: { |
|
|
|
|
|
data: ['SO2(ppb)', '盐分阻抗(Ω)', '环温(℃)', '环湿(RH%)', '锌腐蚀电流(nA)', '铜腐蚀电流(nA)', '铝腐蚀电流(nA)', '钢腐蚀电流(nA)'], |
|
|
|
|
|
}, |
|
|
|
|
|
dataZoom: [{ type: 'inside' }, { type: 'slider' }], |
|
|
|
|
|
xAxis: [ |
|
|
|
|
|
{ |
|
|
|
|
|
type: 'category', |
|
|
|
|
|
axisTick: { alignWithLabel: true }, |
|
|
|
|
|
data: data.time, |
|
|
|
|
|
}, |
|
|
], |
|
|
], |
|
|
|
|
|
yAxis: yAxisData, |
|
|
series: [ |
|
|
series: [ |
|
|
{ |
|
|
{ |
|
|
name: 'SO2(ppb)', |
|
|
name: 'SO2(ppb)', |
|
|