vue柱狀進(jìn)度條圖像的完美實(shí)現(xiàn)方案
前言
本文是對bar進(jìn)度條實(shí)現(xiàn)的2種方案進(jìn)行分享,第一種是很簡單,純css的實(shí)現(xiàn),第二種是echart的實(shí)現(xiàn)。
css的實(shí)現(xiàn)
css實(shí)現(xiàn)很簡單。代碼如下:
<template>
<div class="haoroomflex">
<div v-for="(item,index) in barData" :key="index" class="onebar">
<div class="bar">
<span class="progress" :style="{'height':`${item.value*100}%`}" />
</div>
<div class="sfont">{{ item.date }}</div>
</div>
</div>
</template>
<script>
export default {
props: {
barData: {
type: Array,
default() {
return [
{ date: '', value: 0 },
{ date: '', value: 0 },
{ date: '', value: 0 }
]
}
}
}
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.haoroomflex{display: flex;margin:0 15px;}
.onebar{
flex:1;
text-align: center;
min-width: 30px;
max-width: 100px;
display: inline-block;
.sfont{
color:#999;
font-size:14px;
}
.bar{
height: 160px;
width:24px;
margin:5px auto;
-webkit-border-radius: 24px;
border-radius: 24px;
overflow: hidden;
position: relative;
background: #e5e5e5;
span.progress {
position: absolute;
bottom:0;
height: 0;
width: 100%;
display: block;
-webkit-border-radius: 24px;
border-radius: 24px;
-webkit-transition: height 2s ease-out;
-o-transition: height 2s ease-out;
transition: height 2s ease-out;
background: #3990FF
}
}
}
</style>
效果如下
echart實(shí)現(xiàn)
<template>
<div class="linechartWrap">
<v-chart class="barchart" :options="options" autoresize />
</div>
</template>
<script>
import ECharts from 'vue-echarts'
import 'echarts/lib/chart/bar'
import 'echarts/lib/component/tooltip'
import 'echarts/lib/component/title'
import 'echarts/lib/component/toolbox'
export default {
components: {
'v-chart': ECharts
},
props: {
barData: {
type: Object,
default() {
return {
data: [11, 33, 77],
title: ['07-01', '07-02', '07-03']
}
}
}
},
computed: {
options() {
return {
grid: {
show: 'true',
borderWidth: '0',
height: '72%',
width: '90%',
x: '12%',
y: '20%'
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'none'
},
formatter: '{b0}: {c0}%'
/* formatter: function(params) {
var result = '';
params.forEach(function (item) {
result += item.marker + " " + item.seriesName + " : " + item.value +"</br>";
});
return result;
}*/
},
backgroundColor: '#fff', // 背景色
yAxis: {
show: false, // 是否顯示x軸
type: 'value'
},
xAxis: {
type: 'category',
axisLabel: {
show: true,
textStyle: {
color: '#666' // y軸字體顏色
}
},
splitLine: { show: false }, // 橫向的線
axisTick: { show: false }, // y軸的端點(diǎn)
axisLine: { show: false }, // y軸的線
data: this.barData.title
},
series: [
{
type: 'bar',
itemStyle: {
normal: {
barBorderRadius: 25,
color: '#3990FF'
}
},
barWidth: 25,
data: this.barData.data
},
{
name: '外框',
type: 'bar',
itemStyle: {
normal: {
barBorderRadius: 25,
color: '#e5e5e5' // rgba設(shè)置透明度0.14
}
},
barGap: '-100%',
z: 0,
barWidth: 25,
data: [100, 100, 100]
}
]
}
}
}
}
</script>
代碼地址
代碼已經(jīng)上傳github,地址是: https://github.com/confidence68/bar_precent_css
總結(jié)
以上所述是小編給大家介紹的vue柱狀進(jìn)度條圖像的完美實(shí)現(xiàn)方案,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時(shí)回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
如果你覺得本文對你有幫助,歡迎轉(zhuǎn)載,煩請注明出處,謝謝!
- vue echarts實(shí)現(xiàn)柱狀圖動態(tài)展示
- vue+echart實(shí)現(xiàn)雙柱狀圖
- vue實(shí)現(xiàn)橫向斜切柱狀圖
- vue+echarts實(shí)現(xiàn)堆疊柱狀圖
- vue+echarts實(shí)現(xiàn)進(jìn)度條式柱狀圖
- vue3.0+echarts實(shí)現(xiàn)立體柱圖
- vue基于echarts實(shí)現(xiàn)立體柱形圖
- Vue使用Echarts實(shí)現(xiàn)立體柱狀圖
- 使用D3.js+Vue實(shí)現(xiàn)一個(gè)簡單的柱形圖
- vue echarts實(shí)現(xiàn)橫向柱狀圖
相關(guān)文章
vue使用keep-alive如何實(shí)現(xiàn)多頁簽并支持強(qiáng)制刷新
這篇文章主要介紹了vue使用keep-alive如何實(shí)現(xiàn)多頁簽并支持強(qiáng)制刷新,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-08-08
vue項(xiàng)目登錄頁面實(shí)現(xiàn)記住用戶名和密碼的示例代碼
本文主要介紹了vue項(xiàng)目登錄頁面實(shí)現(xiàn)記住用戶名和密碼的示例代碼,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-07-07
詳解vue beforeRouteEnter 異步獲取數(shù)據(jù)給實(shí)例問題
這篇文章主要介紹了vue beforeRouteEnter 異步獲取數(shù)據(jù)給實(shí)例問題,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-08-08
解決element-ui?el-drawer抽屜el-dialog彈框關(guān)閉優(yōu)化demo
這篇文章主要為大家介紹了解決element-ui?el-drawer抽屜el-dialog彈框關(guān)閉優(yōu)化demo,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪<BR>2023-06-06

