Vue3 Echarts通用的折線圖帶陰影效果實(shí)現(xiàn)
在環(huán)保倉管項(xiàng)目中,做了一個(gè)每月對藥品、消耗品、設(shè)備的進(jìn)出,進(jìn)行統(tǒng)計(jì)百分比,效果好看,后面經(jīng)常在用這個(gè)樣式,以下是詳細(xì)分析:
下載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>運(yùn)行結(jié)果

到此這篇關(guān)于Vue3 Echarts通用的折線圖帶陰影的文章就介紹到這了,更多相關(guān)vue3 echarts折線圖內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
el-form表單el-form-item驗(yàn)證規(guī)則里prop一次驗(yàn)證兩個(gè)或多個(gè)值問題
這篇文章主要介紹了el-form表單el-form-item驗(yàn)證規(guī)則里prop一次驗(yàn)證兩個(gè)或多個(gè)值問題,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2023-05-05
vue使用SVG實(shí)現(xiàn)圓形進(jìn)度條音樂播放
這篇文章主要為大家詳細(xì)介紹了vue使用SVG實(shí)現(xiàn)圓形進(jìn)度條音樂播放,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-04-04
vue3中el-uplod結(jié)合ts實(shí)現(xiàn)圖片粘貼上傳
本文主要介紹了vue3中el-uplod結(jié)合ts實(shí)現(xiàn)圖片粘貼上傳,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2024-07-07
Vue-cli項(xiàng)目部署到Nginx服務(wù)器的方法
這篇文章主要介紹了Vue-cli項(xiàng)目部署到Nginx服務(wù)器的方法,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-11-11
Vue使用自定義指令實(shí)現(xiàn)頁面底部加水印
本文主要實(shí)現(xiàn)給項(xiàng)目的整個(gè)背景加上自定義水印,可以改變水印的文案和字體顏色等,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-06-06
Vue實(shí)現(xiàn)點(diǎn)擊按鈕復(fù)制文本內(nèi)容的例子
今天小編就為大家分享一篇Vue實(shí)現(xiàn)點(diǎn)擊按鈕復(fù)制文本內(nèi)容的例子,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-11-11

