久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長(zhǎng)資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      在 Vue 中實(shí)現(xiàn) Echarts 隨窗體變化

      在 Vue 中實(shí)現(xiàn) Echarts 隨窗體變化

      在 Vue 中實(shí)現(xiàn) Echarts 隨窗體變化

      <p id="myChart" :style="{width: '100%', height: '345px'}"></p> <script> export default { mounted(){     this.drawLine();   },   methods: {     drawLine(){     var myChartContainer = document.getElementById('myChart');      //用于使chart自適應(yīng)寬度,通過(guò)窗體寬計(jì)算容器高寬     var resizeMyChartContainer = function(){      myChartContainer.style.width=(document.body.clientWidth-75)+'px'     }     //設(shè)置容器高寬     resizeMyChartContainer()     // 基于準(zhǔn)備好的dom,初始化echarts實(shí)例     var myChart = this.$echarts.init(myChartContainer)           // 繪制圖表     myChart.setOption({       title: { text: '啟動(dòng)次數(shù)' },       tooltip: {},       xAxis: {         type: 'category',         data: ['2019-02-15', '2019-02-16', '2019-02-17', '2019-02-18', '2019-02-19', '2019-02-20', '2019-02-21']       },       yAxis: {          type:'value'       },       series: [{         type: 'line',         data: [0,0, 0, 7, 0, 0,12],         smooth:true,         symbol: 'circle',          symbolSize: 6,          itemStyle:{            normal:{                            color:'#fc8a0f',              lineStyle:{                color:'#ff9c35'                  }                }              }       }],     });     window.onresize=function(){      resizeMyChartContainer();       myChart.resize();     }    }   }}</script>

      補(bǔ)充知識(shí):echarts 圖表大小隨窗口變動(dòng)而自適應(yīng)變動(dòng)(無(wú)需刷新瀏覽器調(diào)整)

      問(wèn)題提出:

      使用echars做完圖表之后,需要根據(jù)瀏覽器窗口的縮放做自適應(yīng)效果。

      在 Vue 中實(shí)現(xiàn) Echarts 隨窗體變化

      原因分析及解決方案:

      echars的圖標(biāo)實(shí)例事實(shí)上并沒(méi)有主動(dòng)的去綁定resize()事件,就是說(shuō)顯示區(qū)域的大小改變內(nèi)部并不知道,當(dāng)你需要去做一些自適應(yīng)的效果的時(shí)候,需要主動(dòng)綁定這個(gè)時(shí)間才能達(dá)到自使用的效果,常見(jiàn)的如window.onresize = myChart.resize()

      示例:

      var map5 = echarts.init(document.getElementById('map5'));   var option5 = {     backgroundColor: '#def1f9',     color: ['#c23531', '#1875ff'],     title: {       left: 10,       top: 10,       text: 'Bill charts for the past year'     },     // color: ['#1875ff', '#1fe6ab', '#eee119', '#ff3074', '#6f99d9'],     legend: {       top: 30,       right: 30     },     tooltip: {},       xAxis: {type: 'category'},     yAxis: {},     series: [       {type: 'bar'},       {type: 'bar'}     ]   }   map5.setOption(option5);     window.onresize = function () {     setTimeout(function () {        map1.resize()       map2.resize()       map3.resize()       map4.resize()       map5.resize()     },10)   }

      重點(diǎn):

      window.onresize = function () {    map1.resize() ; // 如果有多個(gè)圖標(biāo)變動(dòng),可寫多個(gè) }

      推薦教程:《JS教程》

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)