echarts 自适应窗口大小和数据更新问题

it2024-03-22  60

自适应窗口大小

为了兼容性,需要做到每个图表根据屏幕变化而自适应宽高

单个 / 多个图表均生效 mounted() { window.addEventListener('resize', () => { this.chart.resize(); }); }

或者

// 先要引入resize文件 import resize from './mixins/resize' mounted() { var _this = this window.onresize = function() { _this.$nextTick( _this.DEVChart.resize(), ) } },

数据更新问题

DEVoption:{数据和配置项} this.DEVChart = echarts.init(document.getElementById('DEVChart')) // 加了下面这行代码之前的数据才能被覆盖,渲染出来数据才会显示出来 this.DEVChart.setOption(this.DEVoption, true)
最新回复(0)