vue+echarts實現進度條式柱狀圖
更新時間:2021年09月05日 09:30:58 作者:lannieZ
這篇文章主要為大家詳細介紹了vue+echarts實現進度條式柱狀圖,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了vue+echarts實現進度條式柱狀圖的具體代碼,供大家參考,具體內容如下
效果圖如下

代碼:
<template>
<div class="content-page">
<div class="tab-content">
<div id="myChart1"></div>
</div>
</div>
</template>
<script>
import * as echarts from 'echarts';
export default {
data() {
return {
option: {
color: ["#157ef5"],// 設置柱狀圖的顏色
textStyle: {
color: "#828282"
},
tooltip: {
trigger: "axis",
axisPointer: {
type: "line"
}
},
grid: {
left: "3%",
right: "4%",
bottom: "3%",
containLabel: true
},
xAxis: {
type: "value",
// 設置x軸顯示幾段
min: 0,
max: 100,
interval: 50,
axisTick: { show: false },
axisLine: {
lineStyle: {
color: "transparent"
}
}
},
yAxis: {
type: "category",
data: ["財政收入", "總部經濟"],
axisTick: { show: false },
axisLine: {
lineStyle: {
color: "#e0e0e0"
}
},
inside: true,
textStyle: {
color: "#000"
}
},
series: [
{
type: "bar",
itemStyle: {
color: "#f1f1f1",// 定義柱形的背景色
borderRadius:[0, 10, 10, 0] //定義背景柱形的圓角
},
barGap: "-100%", //設置柱形重合的重要步驟
data: [100, 100],
animation: false, // 關閉動畫效果
barWidth: "22px",// 設置柱形寬度
},
{
type: "bar",
data: [65, 75],
barWidth: "22px",
barGap: "-100%", //設置柱形重合的重要步驟
itemStyle: {
borderRadius:[0, 10, 10, 0],// 定義柱形的圓角
color: function(params) {
var colorList = ['#3C90EB', '#B573F4', '#F9B341', '#F9B341', '#91c7ae'];
return colorList[params.dataIndex]
}
},
}
]
}
}
},
mounted() {
this.getChartData();
},
methods: {
getChartData() {
let myChart1 = echarts.init(document.querySelector("#myChart1"));
myChart1.setOption(this.option); // 設置圖表初始化數據
setTimeout(function() {
window.onresize = function() {
myChart1.resize();// 圖表根據窗口大小進行自適應
};
}, 200);
}
}
}
</script>
<style lang="less" scoped>
#myChart1 {
width: 600px;
height: 400px;
}
</style>
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
淺談Vue3.0新版API之composition-api入坑指南
這篇文章主要介紹了Vue3.0新版API之composition-api入坑指南,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2020-04-04
Vue使用ElementUI動態(tài)修改table單元格背景顏色或文本顏色
本文主要介紹了Vue使用ElementUI動態(tài)修改table單元格背景顏色或文本顏色,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2023-02-02

