vue echarts實現(xiàn)柱狀圖動態(tài)展示
更新時間:2021年09月05日 16:43:23 作者:咖啡有點酷
這篇文章主要為大家詳細(xì)介紹了vue echarts實現(xiàn)柱狀圖動態(tài)展示,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了vue echarts實現(xiàn)柱狀圖動態(tài)展示的具體代碼,供大家參考,具體內(nèi)容如下
輪播圖形式展現(xiàn)
<template> <div class="dan"> <div id="scalesize" :style="{width: '100%', height: '100%'}"></div> </div> </template> <script> import echarts from "echarts"; export default { data() { return { texts: 111 }; }, mounted() { this.drawLine(); }, methods: { drawLine() { // 基于準(zhǔn)備好的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: "聯(lián)建基地", 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: { // 坐標(biāo)軸指示器,坐標(biāo)軸觸發(fā)有效 type: "shadow" // 默認(rèn)為直線,可選為:'line' | 'shadow' } }, grid: { left: "2%", right: "4%", bottom: "14%", top: "16%", containLabel: true }, legend: { data: ["育苗基地", "種植基地", "托管面積", "聯(lián)建基地"], 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-4h59.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); // 高亮當(dāng)前圖形 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>
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
vue2.0 element-ui中el-select選擇器無法顯示選中的內(nèi)容(解決方法)
這篇文章主要介紹了vue2.0 element-ui中的el-select選擇器無法顯示選中的內(nèi)容,在文中小編使用的是element-ui V2.2.3。具體解決方法及示例代碼大家參考下本文2018-08-08element日期選擇器el-date-picker樣式圖文詳解
最近寫的項目里面有一個功能是日期選擇功能,第一反應(yīng)是使用element里面的el-date-picker組件,下面這篇文章主要給大家介紹了關(guān)于element日期選擇器el-date-picker樣式的相關(guān)資料,需要的朋友可以參考下2022-09-09解決vue項目運(yùn)行出現(xiàn)warnings?potentially?fixable?with?the?`--fix
這篇文章主要介紹了解決vue項目運(yùn)行出現(xiàn)warnings?potentially?fixable?with?the?`--fix`?option的報錯問題,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2021-11-11vue.js利用Object.defineProperty實現(xiàn)雙向綁定
這篇文章主要為大家詳細(xì)介紹了vue.js利用Object.defineProperty實現(xiàn)雙向綁定,幫大家解析神秘的Object.defineProperty方法2017-03-03vue.js學(xué)習(xí)之UI組件開發(fā)教程
前端開發(fā)中,隨著業(yè)務(wù)的增多,出于效率的考慮,我們對于組件化開發(fā)的需求也越來越迫切。下面這篇文章主要給大家介紹了關(guān)于vue.js之UI組件開發(fā)的相關(guān)資料,文中介紹的非常詳細(xì),需要的朋友們下面來一起看看吧。2017-07-07