body缩放时echarts鼠标悬浮位置偏移
body增加缩放时,echarts图表中的鼠标与实际位置不符
以下是vue3中的写法
function setZoom() {
// 处理缩放导致canvas定位异常
zoom.value = document.getElementsByTagName('body')[0].style.zoom
console.log('zoom.value', zoom.value)
document.styleSheets[document.styleSheets.length - 1].insertRule('canvas {zoom: ' + 1 / zoom.value + '}')
document.styleSheets[document.styleSheets.length - 1].insertRule('canvas {transform: scale(' + zoom.value + ')}')
document.styleSheets[document.styleSheets.length - 1].insertRule('canvas {transform-origin: 0 0}')
}
setZoom();
window.addEventListener("resize", () => {
setZoom();
});