vue echarts實(shí)現(xiàn)柱狀圖動(dòng)態(tài)展示
本文實(shí)例為大家分享了vue echarts實(shí)現(xiàn)柱狀圖動(dòng)態(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實(shí)例 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>
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- 解決echarts 一條柱狀圖顯示兩個(gè)值,類似進(jìn)度條的問題
- Echarts基本入門之柱狀圖、折線圖通用配置
- Echarts Bar橫向柱狀圖實(shí)例代碼
- Vue使用Echarts實(shí)現(xiàn)立體柱狀圖
- vue echarts實(shí)現(xiàn)橫向柱狀圖
- uniapp引用echarts的詳細(xì)步驟(附柱狀圖實(shí)例)
- echarts動(dòng)態(tài)渲染柱狀圖背景顏色及頂部數(shù)值方法詳解
- 基于vue+echarts實(shí)現(xiàn)柱狀圖漸變色效果(每個(gè)柱子顏色不同)
- Echarts柱狀圖修改柱子顏色漸變及柱子圓角效果實(shí)例
相關(guān)文章
vue2.0 element-ui中el-select選擇器無(wú)法顯示選中的內(nèi)容(解決方法)
這篇文章主要介紹了vue2.0 element-ui中的el-select選擇器無(wú)法顯示選中的內(nèi)容,在文中小編使用的是element-ui V2.2.3。具體解決方法及示例代碼大家參考下本文2018-08-08element日期選擇器el-date-picker樣式圖文詳解
最近寫的項(xiàng)目里面有一個(gè)功能是日期選擇功能,第一反應(yīng)是使用element里面的el-date-picker組件,下面這篇文章主要給大家介紹了關(guān)于element日期選擇器el-date-picker樣式的相關(guān)資料,需要的朋友可以參考下2022-09-09解決vue項(xiàng)目運(yùn)行出現(xiàn)warnings?potentially?fixable?with?the?`--fix
這篇文章主要介紹了解決vue項(xiàng)目運(yùn)行出現(xiàn)warnings?potentially?fixable?with?the?`--fix`?option的報(bào)錯(cuò)問題,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來(lái)看看吧2021-11-11vue項(xiàng)目中?jsconfig.json概念及使用步驟
這篇文章主要介紹了vue項(xiàng)目中?jsconfig.json是什么,本文僅僅簡(jiǎn)單介紹了?jsconfig?.json?的一些基本配置,而?jsconfig?.json提供了大量能使我們快速便捷提高代碼效率的方法,需要的朋友可以參考下2022-07-07vue.js利用Object.defineProperty實(shí)現(xiàn)雙向綁定
這篇文章主要為大家詳細(xì)介紹了vue.js利用Object.defineProperty實(shí)現(xiàn)雙向綁定,幫大家解析神秘的Object.defineProperty方法2017-03-03vue.js學(xué)習(xí)之UI組件開發(fā)教程
前端開發(fā)中,隨著業(yè)務(wù)的增多,出于效率的考慮,我們對(duì)于組件化開發(fā)的需求也越來(lái)越迫切。下面這篇文章主要給大家介紹了關(guān)于vue.js之UI組件開發(fā)的相關(guān)資料,文中介紹的非常詳細(xì),需要的朋友們下面來(lái)一起看看吧。2017-07-07