Vue Echarts實(shí)現(xiàn)柱形圖從右向左滾動(dòng)效果
更新時(shí)間:2023年05月19日 14:54:11 作者:amoureux555
這篇文章主要為大家詳細(xì)介紹了Vue如何利用Echarts實(shí)現(xiàn)柱形圖從右向左滾動(dòng)的效果,文中的示例代碼簡(jiǎn)潔易懂,感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下
效果圖
實(shí)現(xiàn)代碼
vue2 代碼如下
<!-- 橫向柱狀圖測(cè)試結(jié)果 --> <template> <div> <h3>橫向柱狀圖測(cè)試</h3> <div style="width: 500px; height: 500px; background-color: antiquewhite"> <div id="heng" style="width: 100%; height: 100%"></div> </div> </div> </template> <script> // import * as echarts from 'echarts'; export default { name: "hengzhu", data() { return { // data: [1000, 800, 600, 500, 540, 1100, 528, 55, 66, 588, 980, 563, 578, 154, 55, 66, 55, 66, 452, 652] // data: [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000] data: [ 2000, 1900, 1800, 1700, 1600, 1500, 1400, 1300, 1200, 1100, 1000, 900, 900, 800, 700, 600, 500, 400, 300, 200, ], start: 0, end: 5, }; }, created() { this.dingshi(); }, mounted() { this.heng(); // this.dingshi(); }, methods: { heng() { // let that = this; // alert("執(zhí)行"); let chartDom = document.getElementById("heng"); let myChart = this.$echarts.init(chartDom); let option = { title: { text: "World Population", }, tooltip: { trigger: "axis", axisPointer: { type: "shadow", }, }, legend: {}, grid: { left: "3%", right: "4%", bottom: "3%", containLabel: true, }, // xAxis: { yAxis: { type: "value", // boundaryGap: [0, 0.01] // 柱圖距離邊界的距離 }, // yAxis: { xAxis: { type: "category", inverse: false, // ture: 從上到下顯示, 默認(rèn):從下到上顯示,下面的數(shù)值會(huì)跟著變動(dòng) data: [ "aa", "bb", "cc", "dd", "ee", "ff", "gg", "hh", "ii", "jj", "kk", "ll", "mm", "nn", "oo", "pp", "qq", "rr", "ss", "tt", ], }, dataZoom: { type: "inside", // inside: 表示用內(nèi)測(cè)滑塊 startValue: this.start, // 開始顯示的數(shù) endValue: this.end, // 結(jié)束顯示的數(shù) xAxisIndex: [0], // 代表是作用在y軸上的 // yAxisIndex: [0], // 代表是作用在y軸上的 // start: '10', // end: '1' // zoomLock: true, zoomOnMouseWheel: false, // 關(guān)閉滾輪縮放 moveOnMouseWheel: true, // 開啟滾輪平移 moveOnMouseMove: true, // 鼠標(biāo)移動(dòng)能觸發(fā)數(shù)據(jù)窗口平移 }, series: [ { type: "bar", // realtimeSort: true, // 這個(gè)可以與 yAxis-inverse 配合,讓數(shù)據(jù)正序顯示還是逆序顯示 data: this.data, }, ], }; myChart.setOption(option); // setInterval(function () { // this.data = [1000, 800, 600, 500, 540, 1100, 528, 55, 66, 588, 980, 563, 578, 154, 55, 66, 55, 66, 452, 1200] // }, 2000) }, /** 定時(shí)跳動(dòng) */ dingshi() { let that = this; setInterval(function () { if (that.end == that.data.length) { that.start = 0; that.end = 5; } else { that.start = that.start + 1; that.end = that.end + 1; } that.heng(); }, 3000); }, }, }; </script> <style scoped></style>
到此這篇關(guān)于Vue Echarts實(shí)現(xiàn)柱形圖從右向左滾動(dòng)效果的文章就介紹到這了,更多相關(guān)Vue Echarts柱形圖內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Vue實(shí)現(xiàn)視頻播放vue-video-player、dplayer方式
這篇文章主要介紹了Vue實(shí)現(xiàn)視頻播放vue-video-player、dplayer方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2025-04-04vue通過定時(shí)器實(shí)現(xiàn)垂直滾動(dòng)公告
這篇文章主要為大家詳細(xì)介紹了vue通過定時(shí)器實(shí)現(xiàn)垂直滾動(dòng)公告,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-04-04Vue中的 mixins 和 provide/inject詳解
這篇文章主要介紹了Vue中的 mixins 和 provide/inject詳解,本文結(jié)合實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2023-07-07VeeValidate在vue項(xiàng)目里表單校驗(yàn)應(yīng)用案例
這篇文章主要介紹了VeeValidate在vue項(xiàng)目里表單校驗(yàn)應(yīng)用案例,VeeValidate是Vue.js的驗(yàn)證庫,它有很多驗(yàn)證規(guī)則,并支持自定義規(guī)則,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2018-05-05