解决echarts在高分屏下高度异常问题
孙泽辉 Lv5

一直没在乎过window系统下调整分辨率缩放,今天同事笔记本缩放调到175%,直接把我页面整废了,抓紧修一下!

正常看着是没什么毛病的

image

然而调一下系统缩放,到125%

image

其中图表的height算法是这样的

1
2
const clientHeight= (window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight)
const lineChartHeight = clientHeight - 475

lineChart:height = 浏览器高度 - header高度

然而实际缩放的时候,header高度并不是写死的475px,所以我的做法是

1
2
const clientHeight= (window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight)
const lineChartHeight = clientHeight - 475 / ratio
 Comments
Comment plugin failed to load
Loading comment plugin
Powered by Hexo & Theme Keep
Total words 85.5k