Vue3 Echarts通用的折線圖帶陰影效果實現(xiàn)
更新時間:2024年07月04日 14:38:31 作者:陳琦鵬
在環(huán)保倉管項目中,做了一個每月對藥品、消耗品、設(shè)備的進出,進行統(tǒng)計百分比,效果好看,后面經(jīng)常在用這個樣式,下面通過示例代碼分享Vue3 Echarts通用的折線圖帶陰影效果實現(xiàn),感興趣的朋友一起看看吧
在環(huán)保倉管項目中,做了一個每月對藥品、消耗品、設(shè)備的進出,進行統(tǒng)計百分比,效果好看,后面經(jīng)常在用這個樣式,以下是詳細分析:
下載Echarts
//npm npm install echarts --save //淘寶鏡像cnpm(安裝速度快) cnpm install echarts --save //yarn yarn add echarts
代碼示例
<template>
<div id="echartsThree" style="width: 100%;height: 100%;"></div>
</template>
<script setup>
import * as echarts from 'echarts';
import { onMounted,ref } from 'vue';
onMounted(()=>{
getEcharts();
})
const getEcharts = () => {
let chartDom = document.getElementById("echartsThree");
let myChart = echarts.init(chartDom);
let rq = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
let seriesArr = []
let list = [{
name: "藥品",
children: [100, 100, 100, 100, 80, 90, 100, 88, 88, 99, 100, 80]
},
{
name: "消耗品",
children: [50, 50, 40, 40, 35, 40, 30, 35, 30, 30, 25, 25]
},
{
name: "設(shè)備",
children: [75, 75, 55, 55, 45, 50, 40, 30, 35, 40, 50, 50]
}
]
let colorArr = ["0, 62, 246", "0, 193, 142", "253, 148, 67"]
list.forEach((val, index) => {
seriesArr.push({
name: val.name,
type: 'line',
symbolSize: 6,
data: val.children,
areaStyle: {
normal: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
offset: 0,
color: `rgba(${colorArr[index]},.2)`
}, {
offset: 1,
color: 'rgba(255, 255, 255,0)'
}], false)
}
},
itemStyle: {
normal: {
color: `rgb(${colorArr[index]})`
}
},
lineStyle: {
normal: {
width: 2,
shadowColor: `rgba(${colorArr[index]}, .2)`,
shadowBlur: 4,
shadowOffsetY: 25
}
}
})
})
let option = {
backgroundColor: "#fff",
tooltip: {
trigger: 'axis',
axisPointer: {
lineStyle: {
color: '#ddd'
}
},
backgroundColor: 'rgba(255,255,255,1)',
padding: [5, 10],
textStyle: {
color: '#000',
}
},
legend: {
right: "center",
top: "6%",
textStyle: {
color: '#000',
fontSize: 12,
fontWeight: 600
},
data: list.map(val => {
return val.name
})
},
grid: {
left: '2%',
right: '5%',
bottom: '6%',
top: '18%',
containLabel: true
},
xAxis: {
type: 'category',
data: rq,
boundaryGap: false,
splitLine: {
show: true,
interval: 'auto',
lineStyle: {
type: "dashed",
color: ['#cfcfcf']
}
},
axisTick: {
show: false
},
axisLine: {
lineStyle: {
color: '#cfcfcf'
}
},
axisLabel: {
// margin: 10,
textStyle: {
fontSize: 12,
color: "#9e9d9f",
fontWeight: 600
}
}
},
yAxis: [{
name: "(%)",
type: 'value',
splitLine: {
show: true,
lineStyle: {
type: "dashed",
color: ['#cfcfcf']
}
},
axisTick: {
show: false
},
axisLine: {
show: true,
lineStyle: {
fontSize: 12,
color: '#cfcfcf',
}
},
axisLabel: {
textStyle: {
fontSize: 12,
color: "#9e9d9f",
fontWeight: 600
}
},
max: 100
}],
series: seriesArr
};
myChart.setOption(option);
}
</script>運行結(jié)果

到此這篇關(guān)于Vue3 Echarts通用的折線圖帶陰影的文章就介紹到這了,更多相關(guān)vue3 echarts折線圖內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
vue中的v-show,v-if,v-bind的使用示例詳解
這篇文章主要介紹了vue中的v-show,v-if,v-bind的使用,本文通過示例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2023-04-04
Vue2中使用自定義指令實現(xiàn)el-table虛擬列表的代碼示例
在實際開發(fā)中,我們可能會面臨其他需求,例如在 el-table 中無法使用分頁技術(shù)的情況下展示海量數(shù)據(jù),這種情況下,頁面可能會出現(xiàn)卡頓,嚴重時甚至可能引發(fā)瀏覽器崩潰,所以針對這個問題本文給大家介紹了vue2中使用自定義指令實現(xiàn)el-table虛擬列表,需要的朋友可以參考下2025-01-01
vue實現(xiàn)數(shù)字動態(tài)翻牌的效果(開箱即用)
這篇文章主要介紹了vue實現(xiàn)數(shù)字動態(tài)翻牌的效果(開箱即用),實現(xiàn)原理是激將1到9的數(shù)字豎直排版,通過translate移動位置顯示不同數(shù)字,本文通過實例代碼講解,需要的朋友可以參考下2019-12-12
vue router嵌套路由在history模式下刷新無法渲染頁面問題的解決方法
這篇文章主要介紹了vue router嵌套路由在history模式下刷新無法渲染頁面問題的解決方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下2018-01-01

