代码附赠如下
const barChart = echarts.init(indexChart.value);
// barChartOptions 配置项,推荐放在外部引入。
resizeChart(indexChart.value, barChart, state.obj.option);
var div = document.createElement("div");
div.class = "extension";
div.style = "display:none";
barChart.on("mouseover", function (params) {
if (params.componentType === "yAxis") {
const value = params.value;
document.querySelector("body").append(div);
div.style.display="block"
div.className = "active";
div.innerHTML = value;
var xx = params.event.event.pageX - 30;
var yy = params.event.event.pageY + 20;
div.style.top = yy + "px";
div.style.left = xx + "px";
console.log(div.style, "123");
}
});
barChart.on("mouseout", function (params) {
console.log(params, "params");
div.style = "display:none";
});