vue2中使用echarts5.x折线图,tooltip不显示
"vue": "^2.6.14",
"echarts": "^5.4.0",
代码过程
<div id="main" style="height: 400px;width: 100%;">div>
import * as echarts from "echarts";
var myChart;
mounted () {
this.$nextTick(function () {
this.drawLine();
});
},
drawLine () {
var chartDom = document.getElementById("main");
if (myChart != null && myChart != "" && myChart != undefined) {
myChart.dispose(); //销毁
}
myChart = echarts.init(chartDom);
if (this.xAxisData.length == 0) {
document.getElementById("noData").hidden = false;
document.getElementById("main").hidden = true
} else {
document.getElementById("noData").hidden = true;
document.getElementById("main").hidden = false
}
var option;
option = {
tooltip: {
trigger: "item",
show: true,
position: 'inside'
},
color: ["#3ba272", "#fc8452"],
legend: {
data: ["花费", "付费金额"],
},
grid: {
left: "3%",
right: "4%",
bottom: "3%",
containLabel: true,
},
toolbox: {
feature: {
saveAsImage: {},
},
},
xAxis: {
type: "category",
boundaryGap: false,
data: this.xAxisData,
},
yAxis: {
type: "value",
},
series: [
{
showAllSymbol: true, //标注所有数据点
name: "付费金额",
type: "line",
stack: "Total",
data: this.chartsEvent_pay_purchase_amount,
// "label": {
// "fontSize": 14,
// "show": true, //折点显示数值,
// "position": "top"
// },
// "symbolSize": 5,//折线点的大小,必须加这个,折点上方的数值才会显示
},
{
name: "花费",
type: "line",
stack: "Total",
data: this.chartsCharge,
// "label": {
// "fontSize": 14,
// "show": true, //折点显示数值,
// "position": "top"
// },
// "symbolSize": 5,//折线点的大小,必须加这个,折点上方的数值才会显示
},
],
};
myChart.setOption(option);
window.addEventListener('resize', () => {
setTimeout(() => {
myChart.resize()
})
})
}
增加上面注释的代码,只是显示数字,很丑,也不显示tooltip;
就很纳闷,官网拿过来的代码不知道为啥就是不显示,没有改变数据之前也是没有的
echarts.js,css都引入了吗? 你试着用官网的例子看看能不能显示