在iview项目中添加echarts3
生活随笔
收集整理的這篇文章主要介紹了
在iview项目中添加echarts3
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
寫在前面
在即將結束的iview項目中,用到了大量的echarts3內容,簡要記錄下,在iview項目中,如何加載使用echarts3,并使其能夠自適應頁面大小。
開始
通過 id 來綁定 div
methods: {drawExampleChart: function () {this.exampleChart = echarts.init(document.getElementById('chart-div'));this.exampleChart.setOption(this.exampleChartOption);} } 復制代碼$nextTick 是為了確保dom元素已經構建了之后,才進行統計圖的繪制
mounted () {this.$nextTick(() => {this.drawExampleChart();let _self = this;window.addEventListener('resize', function () {_self.exampleChart.resize();});}); } 復制代碼deep: true 表示深度監聽,可監聽對象內的變化
watch: {exampleChartOption: {handler: function (newVal, oldVal) {if (this.exampleChart) {if (newVal) {this.exampleChart.setOption(newVal);} else {this.exampleChart.setOption(oldVal);}} else {this.drawExampleChart();}},deep: true} } 復制代碼總結
該iview項目中,用到了大量的echarts3,包括柱狀圖,折線圖,餅圖,雷達圖,散點圖,基于geojson數據加載的地圖,異性柱狀圖,遷徙圖。
轉載于:https://juejin.im/post/5bea6a0d51882516fa637378
總結
以上是生活随笔為你收集整理的在iview项目中添加echarts3的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 科沃斯机器人双十一全渠道成交额超7亿 两
- 下一篇: keras入门(三)搭建CNN模型破解网