很多时候,我们在修改折线图或者柱状图的图例的时候,会发现前面的小圆点消失了,但是像下面这样,小圆点就会显示出来,并且还能设置数据显示的形式,例如将数据以百分比的形式显示,当数据为空时显示为--
tooltip: {
show: true,
trigger: "axis",
axisPointer: {
type: "line",
},
textStyle: {
align: "left",
fontSize: 12,
},
// formatter: "{b0}<br/>{a0}: {c0}%<br />{a1}: {c1}%<br />{a2}: {c2}%",
formatter: function (params) {
var result = "";
console.log(params);
params.forEach(function (item) {
result +=
item.marker +
" " +
item.seriesName +
" : " +
(item.value ? item.value : "--") +
(item.value ? "%" : "") +
"</br>";
});
return params[0].axisValue + "<br />" + result;
},
position: "left",
},
当数据显示为百分比时,纵坐标也应当以百分比的形式显示,这样数据才不会矛盾
yAxis: {
type: "value",
axisLabel: { formatter: "{value} %" },
},
如有问题,欢迎留言!!