This commit is contained in:
lcw
2025-06-08 22:44:18 +08:00
commit b718751a88
1045 changed files with 314795 additions and 0 deletions

View File

@ -0,0 +1,127 @@
<template>
<div style="height:100%;width:100%" :id="echartsId"></div>
</template>
<script setup>
import * as echarts from "echarts";
import { onMounted, ref, reactive, defineProps, onUnmounted, watch, nextTick } from "vue";
const props = defineProps({
echartsId:{
type:String,
default:'morelineId'
},
smooth:{
type:Boolean,
default:false
},
data:{
type:Object,
default:{
color:[], //['#EB00FF','#F57100']
list:[], //[{label:'总数',val:[80,70,60,50]}, {label:'已处置',val:[70,40,30,80]}, ]
xData:[] ,//['09-01','09-02','09-03','09-04']
}
}
});
watch(()=>props.data,val=>{
nextTick(()=>{
init(val)
})
},{immediate:true,deep:true})
// 初始化
function init (val) {
let color = val.color;
let list = val.list
let series = list.map((item ,idx)=>{
return {
type: "line",
name:item.label,
data:item.val,
itemStyle:{normal: { color: color[idx] }},
smooth:props.smooth,
showSymbol:false,
areaStyle: {
normal: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
offset: 0,
color: 'rgba(199, 237, 250,0.5)'
}, {
offset: 1,
color: 'rgba(199, 237, 250,0.2)'
}], false)
}
},
}
})
chartFn(series)
}
function chartFn(series) {
var myChart = echarts.init(document.getElementById(props.echartsId));
var option = {
grid: {
top: "20%",
right: "6%",
left: "2%",
bottom: "3%",
containLabel:true
},
legend:{
data:props.data.list.map(v=>{return v.label}),
textStyle: { color: "#333"},
icon:'diamond', //arrow,diamond,roundRect,rect,none,circle
itemWidth:16,
itemHeight:8,
itemGap:5
},
tooltip: {
trigger: "axis",
axisPointer: {
lineStyle: { color: "#ddd" }
},
backgroundColor: "rgba(255,255,255,1)",
padding: [5, 10],
textStyle: { color: "#7588E4" },
extraCssText: "box-shadow: 0 0 5px rgba(0,0,0,0.3)"
},
xAxis: {
type: "category",
data:props.data.xData,
axisTick: { show: false },
axisLine: { show: false },
axisLabel: { color: "#fff" },
axisLabel: {
show: true,
color: "#333",
interval: 0, // 强制显示所有标签
// rotate: 15, // 标签旋转角度
// formatter: function(value) { return value.split("").join("\n");}
}
},
yAxis: {
type: "value",
splitLine: {
show:true ,
lineStyle: {
type:'dashed',
color: "rgba(14,95,255,0.5)"
}
},
axisTick: { show: false },
axisLine: { show: false },
axisLabel: { color: "#333" },
},
series:series
};
option && myChart.setOption(option);
window.addEventListener('resize',function(){
myChart.resize();
})
}
</script>
<style lang="scss" scoped>
</style>