您好,登錄后才能下訂單哦!
這篇文章主要介紹“vue echarts實現的柱狀圖動態效果代碼分享”,在日常操作中,相信很多人在vue echarts實現的柱狀圖動態效果代碼分享問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”vue echarts實現的柱狀圖動態效果代碼分享”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!
本文實例為大家分享了vue echarts實現柱狀圖動態展示的具體代碼,供大家參考,具體內容如下
輪播圖形式展現
<template> <div class="dan"> <div id="scalesize" :></div> </div> </template> <script> import echarts from "echarts"; export default { data() { return { texts: 111 }; }, mounted() { this.drawLine(); }, methods: { drawLine() { // 基于準備好的dom,初始化echarts實例 let myChart = this.$echarts.init(document.getElementById("scalesize")); var fanfa = [ { name: "育苗基地", type: "bar", barWidth: "15%", itemStyle: { normal: { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ { offset: 0, color: "#fccb05" }, { offset: 1, color: "#f5804d" } ]), barBorderRadius: 12 } }, data: [100, 120, 160, 180, 220, 400] }, { name: "種植基地", type: "bar", barWidth: "15%", itemStyle: { normal: { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ { offset: 0, color: "#8bd46e" }, { offset: 1, color: "#09bcb7" } ]), barBorderRadius: 11 } }, data: [270, 320, 420, 650, 821,907] }, { name: "托管面積", type: "bar", barWidth: "15%", itemStyle: { normal: { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ { offset: 0, color: "#248ff7" }, { offset: 1, color: "#6851f1" } ]), barBorderRadius: 11 } }, data: [140, 180, 215, 320, 396, 520] }, { name: "聯建基地", type: "bar", barWidth: "15%", itemStyle: { normal: { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ { offset: 0, color: "#B88080" }, { offset: 1, color: "#983A3A" } ]), barBorderRadius: 11 } }, data: [140, 180, 215, 320, 396, 420] } ]; myChart.setOption({ tooltip: { trigger: "axis", axisPointer: { // 坐標軸指示器,坐標軸觸發有效 type: "shadow" // 默認為直線,可選為:'line' | 'shadow' } }, grid: { left: "2%", right: "4%", bottom: "14%", top: "16%", containLabel: true }, legend: { data: ["育苗基地", "種植基地", "托管面積", "聯建基地"], right: 10, top: 12, textStyle: { color: "#fff" }, itemWidth: 12, itemHeight: 10 // itemGap: 35 }, xAxis: { type: "category", data: [ "2014", "2015", "2016", "2017", "2018", "2019" ], axisLine: { lineStyle: { color: "white" } }, axisLabel: { // interval: 0, // rotate: 40, textStyle: { fontFamily: "Microsoft YaHei" } } }, yAxis: { type: "value", axisLine: { show: false, lineStyle: { color: "white" } }, splitLine: { show: true, lineStyle: { color: "rgba(255,255,255,0.3)" } }, axisLabel: {} }, dataZoom: [ { show: true, height: 12, xAxisIndex: [0], bottom: "8%", handleIcon: "path://M306.1,413c0,2.2-1.8,4-4,4h-59.8c-2.2,0-4-1.8-4-4V200.8c0-2.2,1.8-4,4-4h69.8c2.2,0,4,1.8,4,4V413z", handleSize: "110%", handleStyle: { color: "#d3dee5" }, textStyle: { color: "#fff" }, borderColor: "#90979c" }, { type: "inside", show: true, height: 15, start: 1, end: 35 } ], series: fanfa }); let app = { currentIndex: -1 }; setInterval(function() { let dataLen = fanfa[1].data.length; // 取消之前高亮的圖形 myChart.dispatchAction({ type: "downplay", seriesIndex: 0, dataIndex: app.currentIndex }); app.currentIndex = (app.currentIndex + 1) % dataLen; //console.log(app.currentIndex); // 高亮當前圖形 myChart.dispatchAction({ type: "highlight", seriesIndex: 0, dataIndex: app.currentIndex }); // 顯示 tooltip myChart.dispatchAction({ type: "showTip", seriesIndex: 0, dataIndex: app.currentIndex }); }, 1000); window.onresize = myChart.resize; } } }; </script> <style lang="less" scoped> .dan { height: 90%; } </style>
到此,關于“vue echarts實現的柱狀圖動態效果代碼分享”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續學習更多相關知識,請繼續關注億速云網站,小編會繼續努力為大家帶來更多實用的文章!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。