| <div class="echart-wrap" :ref="wrapId" :id="wrapId" > |
| <div :ref="chartsId" :id="chartsId" ></div> |
| </div> |
复制
| props: { |
| wrapId: { |
| |
| type: String, |
| default: 'wrapId', |
| }, |
| chartsId: { |
| |
| type: String, |
| default: 'chartsId', |
| }, |
复制
| .echart-wrap{ |
| width: 100%; |
| height: 100%; |
| position: relative; |
| } |
复制
| this.myChart.setOption(this.options, true); |
| window.addEventListener('resize', () => { |
| this.echartsResize(this.myChart, this.chartsId, this.wrapId); |
| }); |
复制
| |
| |
| |
| |
| |
| |
| |
| |
| echartsResize(myChart, domId, domWrapId) { |
| |
| this.echartsSetWH(domId, domWrapId); |
| if (myChart) { |
| myChart.resize(); |
| } |
| }, |
| |
复制
| |
| |
| |
| |
| |
| |
| |
| echartsSetWH(domId, domWrapId) { |
| const worldMapContainer = document.getElementById(domId); |
| |
| if (worldMapContainer) { |
| worldMapContainer.style.width = `${document.getElementById(domWrapId).offsetWidth - 5}px`; |
| worldMapContainer.style.height = `${document.getElementById(domWrapId).offsetHeight - 5}px`; |
| } |
| }, |
复制
Echarts图表自适应宽高大小