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 @@ ...@@ -63,10 +63,7 @@
type: 'value' type: 'value'
} }
], ],
tooltip: { tooltip: that.dealTooltip(that.elementInfo.option.tooltip),
...that.elementInfo.option.tooltip,
trigger: "axis"
},
toolbox: { toolbox: {
...that.elementInfo.option.toolbox, ...that.elementInfo.option.toolbox,
feature: { feature: {
...@@ -125,6 +122,28 @@ ...@@ -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 @@ ...@@ -49,10 +49,7 @@
...that.elementInfo.option.xAxis, ...that.elementInfo.option.xAxis,
data: categories data: categories
}, },
tooltip: { tooltip: that.dealTooltip(that.elementInfo.option.tooltip),
...that.elementInfo.option.tooltip,
trigger: "axis"
},
toolbox: { toolbox: {
...that.elementInfo.option.toolbox, ...that.elementInfo.option.toolbox,
feature: { feature: {
...@@ -111,6 +108,28 @@ ...@@ -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 @@ ...@@ -51,10 +51,7 @@
...that.elementInfo.option.xAxis, ...that.elementInfo.option.xAxis,
data: categories data: categories
}, },
tooltip: { tooltip: that.dealTooltip(that.elementInfo.option.tooltip),
...that.elementInfo.option.tooltip,
trigger: "axis"
},
toolbox: { toolbox: {
...that.elementInfo.option.toolbox, ...that.elementInfo.option.toolbox,
feature: { feature: {
...@@ -113,6 +110,28 @@ ...@@ -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 { ...@@ -40,19 +40,17 @@ export default {
devicePixelRatio: canvasDpr devicePixelRatio: canvasDpr
}) })
canvas.setChart(chart) canvas.setChart(chart)
const { series } = this.elementData.dataList const { series } = this.elementData.dataList
const that = this
this.ec.option = { this.ec.option = {
...this.elementInfo.option, ...that.elementInfo.option,
color: ['#1089E7', '#F57474', '#56D0E3', '#F8B448', '#8B78F6'], color: ['#1089E7', '#F57474', '#56D0E3', '#F8B448', '#8B78F6'],
tooltip: { tooltip: that.dealTooltip(that.elementInfo.option.tooltip),
...this.elementInfo.option.tooltip, series: that.dealSeriesData(series)
trigger: 'item'
},
series: this.dealSeriesData(series)
} }
chart.setOption(this.ec.option) chart.setOption(that.ec.option)
chart.on('click', event => { chart.on('click', event => {
this.handleEchartsClick(event) that.handleEchartsClick(event)
}) })
return chart return chart
}, },
...@@ -65,6 +63,29 @@ export default { ...@@ -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) { dealSeriesData (data) {
if(!data) return if(!data) return
const series = [{ 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