echarts 图标根据页面变动自刷新

解决方式: 在图表方法中添加 window.addEventListener(“resize”, this.chart.resize); initChart()

解决方式:
在图表方法中添加 window.addEventListener(“resize”, this.chart.resize);

 initChart() {this.chart = echarts.init(this.$el, 'macarons');//重点window.addEventListener("resize", this.chart.resize);this.option={title: {text: '***统计图',left: 'center',textStyle: {fontSize: "28",}},tooltip: {trigger: 'axis',axisPointer: {type: 'shadow'}},legend: {left: '80%',top: "30",data: ['债务余额结构']},toolbox: {show: true, //是否显示工具栏组件orient: 'vertical', //工具栏 icon 的布局朝向left: 'right',top: 'center',feature: { //各工具配置项dataView: { //数据视图工具,可以展现当前图表所用的数据,编辑后可以动态更新readOnly: false},saveAsImage: {} //保存图片}},grid: {left: '2%',right: '8%',bottom: '3%',containLabel: true},xAxis: {type: 'value',boundaryGap: [0, 0.01]},yAxis: {type: 'category',data: []},series: [{name: '债务余额结构',type: 'bar',label: {normal: {position: 'right',show: true}},data: []}]}this.chart.setOption(this.option)},