echarts radar的提示框不显示,但是控制台打印又能打印出数据
这是我的具体代码,麻烦有遇到这种情况的能帮我看一下,感谢
` drawLine() {
let myChart = this.$echarts.init(document.getElementById("smain"));
myChart.setOption({
tooltip : {
show : true,
trigger: 'item',
formatter : function(params){
console.log(params)
},
},
angleAxis: {
axisLine: {
//坐标 轴线
show: true,
lineStyle: {
color: "rgba(255,255,255,0.2)"
}
}
},
legend: {
},
radiusAxis: {
max: 100,
min: 0,
interval: 20,
splitLine: false,
axisLabel: {
color: "#2458FF"
}
},
polar: {
radius : this.r1
},
radar: {
nameGap: 3,
radius : this.r2,
name: {
textStyle: {
color: "#2458FF",
backgroundColor: "transparent",
borderRadius: 3,
padding: [10, 5]
},
formatter: text => {
if (
text == "50米跑" ||
text == "立定跳远" ||
text == "1000米跑" ||
text == "一分钟仰卧起坐" ||
text == "引体向上" ||text == '坐位体前屈'
) {
text = text.replace(/\S{2}/g, function(match) {
return match + "\n";
});
}
return text;
}
},
indicator: this.$store.state.homedataStore.sportsinfo
.sportsname,
splitArea: {
show: true,
areaStyle: {
color: ["transparent"] // 图表背景网格的颜色
}
},
splitLine: {
show: true,
lineStyle: {
width: 1,
color: "rgba(255,255,255,0.2)" // 设置网格的颜色
}
},
axisLine: {
// 坐标轴线
show: true,
lineStyle: {
width: 1,
color: "rgba(255,255,255,0.2)" // 设置网格的颜色
}
}
},
series: [
{
type: "radar",
//symbol: "none", // 去掉图表中各个图区域的边框线拐点
data: [
{
name : this.$store.state.homedataStore
.sportsinfo.dataname,
value: this.$store.state.homedataStore
.sportsinfo.sportsvalue
}
],
itemStyle: {
color: "#fff",
borderColor: "#65d6ff"
},
lineStyle: {
color: "#2458FF"
},
areaStyle: {
color: "rgba(255,255,255,0.08)"
}
}
]
});
$(window).resize(function() {
myChart.resize();
});
}`
楼主,你好~
问题出自你的
tooltip
中的formatter
函数,必须要return
的。可以将其去掉,试试看。或者里面加入你自己需要格式化的内容,即可。如下面代码:如有帮助,麻烦点击下采纳,谢谢~