Commit 9cdf8a62 authored by leon's avatar leon

feat: add double yaxis

parent c7f97eaa
......@@ -49,6 +49,13 @@
if(that.elementInfo.option.colorConfig && 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.elementInfo.option,
color: color,
......@@ -56,6 +63,7 @@
...that.elementInfo.option.xAxis,
data: categories
},
yAxis: yAxis,
tooltip: that.dealTooltip(that.elementInfo.option.tooltip),
toolbox: {
...that.elementInfo.option.toolbox,
......@@ -138,6 +146,27 @@
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 @@
}
}
}
if (that.elementInfo.option.yAxis.showDouble) {
const yAxisIndex = data.length - 1 === index ? 1 : 0
return { ...item, ...config, yAxisIndex: yAxisIndex}
}
return {
...item,
...config
......
......@@ -48,6 +48,13 @@
if(that.elementInfo.option.colorConfig && 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.elementInfo.option,
color: color,
......@@ -55,6 +62,7 @@
...that.elementInfo.option.xAxis,
data: categories
},
yAxis: yAxis,
tooltip: that.dealTooltip(that.elementInfo.option.tooltip),
toolbox: {
...that.elementInfo.option.toolbox,
......@@ -137,13 +145,34 @@
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) {
if (!data) return []
const that = this
const newData = data.map(item => {
const newData = data.map((item, index) => {
const config = {
type: 'line',
...that.elementInfo.option.line,
......@@ -155,6 +184,10 @@
},
}
}
if (that.elementInfo.option.yAxis.showDouble) {
const yAxisIndex = data.length - 1 === index ? 1 : 0
return { ...item, ...config, yAxisIndex: yAxisIndex}
}
return {
...item,
...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