Commit 2a5ad7e6 authored by leon's avatar leon

fix: bar line and pie add tooltip formatter

parent 05399770
This diff is collapsed.
......@@ -63,10 +63,7 @@
type: 'value'
}
],
tooltip: {
...that.elementInfo.option.tooltip,
trigger: "axis"
},
tooltip: that.dealTooltip(that.elementInfo.option.tooltip),
toolbox: {
...that.elementInfo.option.toolbox,
feature: {
......@@ -125,6 +122,28 @@
}
})
},
/**
*
* @param tooltip 表单的tooltip设置
*/
dealTooltip(tooltip) {
if (!tooltip) {
return
}
if (tooltip.formatter && tooltip.formatter.length) {
return {
...tooltip,
formatter: (val) => {
return this.$u.common.converFunction(tooltip.formatter, val)
},
trigger: "axis"
}
}
return {
...tooltip,
trigger: "axis"
}
},
/**
* 处理数据
*/
......
......@@ -49,10 +49,7 @@
...that.elementInfo.option.xAxis,
data: categories
},
tooltip: {
...that.elementInfo.option.tooltip,
trigger: "axis"
},
tooltip: that.dealTooltip(that.elementInfo.option.tooltip),
toolbox: {
...that.elementInfo.option.toolbox,
feature: {
......@@ -111,6 +108,28 @@
}
})
},
/**
*
* @param tooltip 表单的tooltip设置
*/
dealTooltip(tooltip) {
if (!tooltip) {
return
}
if (tooltip.formatter && tooltip.formatter.length) {
return {
...tooltip,
formatter: (val) => {
return this.$u.common.converFunction(tooltip.formatter, val)
},
trigger: "axis"
}
}
return {
...tooltip,
trigger: "axis"
}
},
/**
* 处理数据
*/
......
......@@ -51,10 +51,7 @@
...that.elementInfo.option.xAxis,
data: categories
},
tooltip: {
...that.elementInfo.option.tooltip,
trigger: "axis"
},
tooltip: that.dealTooltip(that.elementInfo.option.tooltip),
toolbox: {
...that.elementInfo.option.toolbox,
feature: {
......@@ -113,6 +110,28 @@
}
})
},
/**
*
* @param tooltip 表单的tooltip设置
*/
dealTooltip(tooltip) {
if (!tooltip) {
return
}
if (tooltip.formatter && tooltip.formatter.length) {
return {
...tooltip,
formatter: (val) => {
return this.$u.common.converFunction(tooltip.formatter, val)
},
trigger: "axis"
}
}
return {
...tooltip,
trigger: "axis"
}
},
/**
* 处理数据
*/
......
......@@ -40,19 +40,17 @@ export default {
devicePixelRatio: canvasDpr
})
canvas.setChart(chart)
const { series } = this.elementData.dataList
const { series } = this.elementData.dataList
const that = this
this.ec.option = {
...this.elementInfo.option,
...that.elementInfo.option,
color: ['#1089E7', '#F57474', '#56D0E3', '#F8B448', '#8B78F6'],
tooltip: {
...this.elementInfo.option.tooltip,
trigger: 'item'
},
series: this.dealSeriesData(series)
tooltip: that.dealTooltip(that.elementInfo.option.tooltip),
series: that.dealSeriesData(series)
}
chart.setOption(this.ec.option)
chart.setOption(that.ec.option)
chart.on('click', event => {
this.handleEchartsClick(event)
that.handleEchartsClick(event)
})
return chart
},
......@@ -65,6 +63,29 @@ export default {
}
},
/**
*
* @param tooltip 表单的tooltip设置
*/
dealTooltip (tooltip) {
if(!tooltip) {
return
}
if(tooltip.formatter && tooltip.formatter.length) {
return {
...tooltip,
formatter: (val) => {
return this.$u.common.converFunction(tooltip.formatter, val)
},
trigger: "item"
}
}
return {
...tooltip,
trigger: "item"
}
},
dealSeriesData (data) {
if(!data) return
const series = [{
......
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