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í)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
詳解vue中的父子傳值雙向綁定及數(shù)據(jù)更新問(wèn)題
這篇文章主要介紹了vue中的父子傳值雙向綁定及數(shù)據(jù)更新問(wèn)題,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2019-06-06
Vue2中無(wú)法檢測(cè)到數(shù)組變動(dòng)的原因及解決
由于某些限制,vue2不能檢測(cè)到某些情況下數(shù)組的變動(dòng),本文就將具體講解這兩種限制的解決思路2021-06-06
vue2.0與vue3.0及vue與react的區(qū)別及說(shuō)明
這篇文章主要介紹了vue2.0與vue3.0及vue與react的區(qū)別及說(shuō)明,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-10-10
vue-cli 3.x 配置Axios(proxyTable)跨域代理方法
今天小編就為大家分享一篇vue-cli 3.x 配置Axios(proxyTable)跨域代理方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-09-09
Vue?使用postMessage?實(shí)現(xiàn)父子跨域通信
這篇文章主要介紹了Vue應(yīng)用?postMessage?實(shí)現(xiàn)父子跨域通信,通過(guò)示例介紹了postMessage的使用,本文結(jié)合示例代碼給大家介紹的非常詳細(xì),需要的朋友可以參考下2022-12-12
Vue使用vue-area-linkage實(shí)現(xiàn)地址三級(jí)聯(lián)動(dòng)效果的示例
很多時(shí)候我們需要使用地址三級(jí)聯(lián)動(dòng),即省市區(qū)三級(jí)聯(lián)動(dòng),這篇文章主要介紹了Vue使用vue-area-linkage實(shí)現(xiàn)地址三級(jí)聯(lián)動(dòng)效果的示例,感興趣的小伙伴們可以參考一下2018-06-06
vue中axios的封裝問(wèn)題(簡(jiǎn)易版攔截,get,post)
這篇文章主要介紹了vue中axios的封裝問(wèn)題(簡(jiǎn)易版攔截,get,post),需要的朋友可以參考下2018-06-06
vuecli3.0腳手架搭建及不同的打包環(huán)境配置vue.config.js的詳細(xì)過(guò)程
這篇文章主要介紹了vuecli3.0腳手架搭建及不同的打包環(huán)境配置vue.config.js的詳細(xì)過(guò)程,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2023-01-01
Vue實(shí)現(xiàn)導(dǎo)航欄點(diǎn)擊當(dāng)前標(biāo)簽變色功能
這篇文章主要為大家詳細(xì)介紹了Vue實(shí)現(xiàn)導(dǎo)航欄點(diǎn)擊當(dāng)前標(biāo)簽變色功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-05-05
利用Vue實(shí)現(xiàn)卡牌翻轉(zhuǎn)的特效
這篇文章主要介紹了如何利用Vue實(shí)現(xiàn)一個(gè)春節(jié)抽???yè)面,采用了卡牌翻轉(zhuǎn)的形式。文中的實(shí)現(xiàn)方法講解詳細(xì),快跟隨小編一起學(xué)習(xí)一下吧2022-02-02

