Commit 9cdf8a62 authored by leon's avatar leon

feat: add double yaxis

parent c7f97eaa
...@@ -49,6 +49,13 @@ ...@@ -49,6 +49,13 @@
if(that.elementInfo.option.colorConfig && that.elementInfo.option.colorConfig.value) { if(that.elementInfo.option.colorConfig && that.elementInfo.option.colorConfig.value) {
color = that.elementInfo.option.colorConfig.value color = that.elementInfo.option.colorConfig.value
} }
var yAxis = that.dealYAxis({...that.elementInfo.option.yAxis})
if (yAxis.showDouble) {
yAxis = [
that.dealYAxis({ ...that.elementInfo.option.yAxis}),
that.dealYAxis({ ...that.elementInfo.option.yAxis, ...that.elementInfo.option.yAxis.second })
]
}
that.ec.option = { that.ec.option = {
...that.elementInfo.option, ...that.elementInfo.option,
color: color, color: color,
...@@ -56,6 +63,7 @@ ...@@ -56,6 +63,7 @@
...that.elementInfo.option.xAxis, ...that.elementInfo.option.xAxis,
data: categories data: categories
}, },
yAxis: yAxis,
tooltip: that.dealTooltip(that.elementInfo.option.tooltip), tooltip: that.dealTooltip(that.elementInfo.option.tooltip),
toolbox: { toolbox: {
...that.elementInfo.option.toolbox, ...that.elementInfo.option.toolbox,
...@@ -138,6 +146,27 @@ ...@@ -138,6 +146,27 @@
trigger: "axis" trigger: "axis"
} }
}, },
/**
*
* @param yAxis 表单的yAxis设置
*/
dealYAxis(yAxis) {
if (!yAxis) {
return
}
if (yAxis.axisLabel.formatter && yAxis.axisLabel.formatter.length) {
return {
...yAxis,
axisLabel: {
...yAxis.axisLabel,
formatter: (val) => {
return this.$u.common.converFunction(yAxis.axisLabel.formatter, val)
},
}
}
}
return yAxis
},
/** /**
* 处理数据 * 处理数据
*/ */
...@@ -156,6 +185,10 @@ ...@@ -156,6 +185,10 @@
} }
} }
} }
if (that.elementInfo.option.yAxis.showDouble) {
const yAxisIndex = data.length - 1 === index ? 1 : 0
return { ...item, ...config, yAxisIndex: yAxisIndex}
}
return { return {
...item, ...item,
...config ...config
......
...@@ -48,6 +48,13 @@ ...@@ -48,6 +48,13 @@
if(that.elementInfo.option.colorConfig && that.elementInfo.option.colorConfig.value) { if(that.elementInfo.option.colorConfig && that.elementInfo.option.colorConfig.value) {
color = that.elementInfo.option.colorConfig.value color = that.elementInfo.option.colorConfig.value
} }
var yAxis = that.dealYAxis({...that.elementInfo.option.yAxis})
if (yAxis.showDouble) {
yAxis = [
that.dealYAxis({ ...that.elementInfo.option.yAxis}),
that.dealYAxis({ ...that.elementInfo.option.yAxis, ...that.elementInfo.option.yAxis.second})
]
}
that.ec.option = { that.ec.option = {
...that.elementInfo.option, ...that.elementInfo.option,
color: color, color: color,
...@@ -55,6 +62,7 @@ ...@@ -55,6 +62,7 @@
...that.elementInfo.option.xAxis, ...that.elementInfo.option.xAxis,
data: categories data: categories
}, },
yAxis: yAxis,
tooltip: that.dealTooltip(that.elementInfo.option.tooltip), tooltip: that.dealTooltip(that.elementInfo.option.tooltip),
toolbox: { toolbox: {
...that.elementInfo.option.toolbox, ...that.elementInfo.option.toolbox,
...@@ -137,13 +145,34 @@ ...@@ -137,13 +145,34 @@
trigger: "axis" trigger: "axis"
} }
}, },
/**
*
* @param yAxis 表单的yAxis设置
*/
dealYAxis(yAxis) {
if (!yAxis) {
return
}
if (yAxis.axisLabel.formatter && yAxis.axisLabel.formatter.length) {
return {
...yAxis,
axisLabel: {
...yAxis.axisLabel,
formatter: (val) => {
return this.$u.common.converFunction(yAxis.axisLabel.formatter, val)
},
}
}
}
return yAxis
},
/** /**
* 处理数据 * 处理数据
*/ */
dealSeriesData(data) { dealSeriesData(data) {
if (!data) return [] if (!data) return []
const that = this const that = this
const newData = data.map(item => { const newData = data.map((item, index) => {
const config = { const config = {
type: 'line', type: 'line',
...that.elementInfo.option.line, ...that.elementInfo.option.line,
...@@ -155,6 +184,10 @@ ...@@ -155,6 +184,10 @@
}, },
} }
} }
if (that.elementInfo.option.yAxis.showDouble) {
const yAxisIndex = data.length - 1 === index ? 1 : 0
return { ...item, ...config, yAxisIndex: yAxisIndex}
}
return { return {
...item, ...item,
...config ...config
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment