更新研判首页和echarts组件

This commit is contained in:
2025-05-19 15:50:38 +08:00
parent 1fafd27208
commit 6555a6d277
7 changed files with 276 additions and 106 deletions

View File

@ -3,6 +3,7 @@
</template>
<script setup>
import * as echarts from "echarts";
import { el } from "element-plus/es/locale.mjs";
import { on } from "element-plus/lib/utils";
import { onMounted, ref, reactive, defineProps, onUnmounted, watch, nextTick } from "vue";
@ -16,6 +17,9 @@ const props = defineProps({
default:{
xData:[],
color:[],
stack:false, //fasle 并排展示 true 堆叠展示
barWidth:'12px',
labelColor:'#fff', //横坐标颜色 - 纵坐标颜色 - 标题颜色
list:[]
}
}
@ -29,23 +33,30 @@ watch(()=>props.data,val=>{
function init (val) {
let color = val.color;
let list = val.list
let total = 0
let series = list.map((item ,idx)=>{
let obj = {
type: "bar",
stack:'total',
name:item.label,
data:item.val,
barGap:'80%',
barWidth: "30px",
itemStyle:{normal: { color: color[idx] }}
barWidth: val.barWidth ? val.barWidth: "12px",
}
if(item.label == '总数'){
obj.stack = ''
obj.z = -1
obj.barGap = '-100%'
obj.label = { normal:{show:true,position:'top',color:'#EB00FF'} }
// 是否渐变
if( Array.isArray(color[idx]) && color[idx].length > 0){
obj.label = { normal:{show:true,position:'top',color:color[idx][0] ? color[idx][0] : '#EB00FF'} }
obj.itemStyle = {
normal: {
color: new echarts.graphic.LinearGradient(0,0,0,1,[{ offset: 0, color: color[idx][0] },{ offset: 1, color: color[idx][1] }],false)
}
}
}else{
obj.itemStyle = {normal: {color: color[idx] ? color[idx] : '#EB00FF'}}
obj.label = { normal:{show:true,position:'top',color:color[idx] ? color[idx] : '#EB00FF'} }
}
// 是否堆叠
if(val.stack) obj.stack = 'total';
return obj;
})
chartFn(series)
@ -55,15 +66,15 @@ function chartFn(series) {
var myChart = echarts.init(document.getElementById(props.echartsId));
var option = {
grid: {
top: "30%",
top: "12%",
right: "2%",
left: "2%",
bottom: "3%",
bottom: "5%",
containLabel:true
},
legend:{
data:props.data.list.map(v=>{return v.label}),
textStyle: { color: "#fff"},
textStyle: { color: props.data.labelColor || "#fff" },
icon:'diamond', //arrow,diamond,roundRect,rect,none,circle
itemWidth:16,
itemHeight:8,
@ -84,7 +95,7 @@ function chartFn(series) {
data:props.data.xData,
axisTick: { show: false },
axisLine: { show: false },
axisLabel: { color: "#fff",magin:20 },
axisLabel: { color: props.data.labelColor || "#fff",magin:20 },
},
yAxis: {
type: "value",
@ -97,7 +108,7 @@ function chartFn(series) {
},
axisTick: { show: false },
axisLine: { show: false },
axisLabel: { color: "#fff" },
axisLabel: { color: props.data.labelColor || "#fff"},
},
series:series
};

View File

@ -16,6 +16,10 @@ const props = defineProps({
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']
labelColor:'#000', //横坐标颜色 - 纵坐标颜色 - 标题颜色
rotate:0, //横坐标旋转角度
interval:0, //横坐标间隔
isVertical:false,//是否竖排垂直展示
}
}
});
@ -66,7 +70,7 @@ function chartFn(series) {
},
legend:{
data:props.data.list.map(v=>{return v.label}),
textStyle: { color: "#fff"},
textStyle: { color: props.data.labelColor || "#fff" },
icon:'diamond', //arrow,diamond,roundRect,rect,none,circle
itemWidth:16,
itemHeight:8,
@ -87,13 +91,12 @@ function chartFn(series) {
data:props.data.xData,
axisTick: { show: false },
axisLine: { show: false },
axisLabel: { color: "#fff" },
axisLabel: {
show: true,
color: "#fff",
interval: 0, // 强制显示所有标签
// rotate: 15, // 标签旋转角度
// formatter: function(value) { return value.split("").join("\n");}
color: props.data.labelColor || "#fff",
interval: props.data.interval || 0, // 强制显示所有标签
rotate: props.data.rotate || 0, // 标签旋转角度
formatter: function(value) { return props.data.isVertical ? value.split("").join("\n") : value}
}
},
yAxis: {
@ -107,7 +110,7 @@ function chartFn(series) {
},
axisTick: { show: false },
axisLine: { show: false },
axisLabel: { color: "#fff" },
axisLabel: { color: props.data.labelColor || "#fff", },
},
series:series
};

View File

@ -53,7 +53,7 @@
</el-popover>
<ul class="leftBtn-yjbtn flex">
<li class="leftBtn-item" @click.stop="handleBtns(it)" :class="btnsActive == it ? 'yjbtnActive' : ''" v-for="it in btns.leftBtn" :key="it">
<li class="leftBtn-item pointer" @click.stop="handleBtns(it)" :class="btnsActive == it ? 'yjbtnActive' : ''" v-for="it in btns.leftBtn" :key="it">
<span class="btms">{{ it }}</span>
</li>
</ul>
@ -126,7 +126,7 @@ const router = useRouter();
const route = useRoute();
const btns = reactive({
rightBtn: ["四色预警", "重点人群"],
leftBtn: ["预警布控",'网上会议室'],
leftBtn: ["预警布控",'研判首页'],
moreBtn:['退出登录',]
});
const btnsActive = ref("");
@ -159,8 +159,8 @@ const handleBtns = (val) => {
case "四色预警":
router.push("/IdentityManage");
break;
case "网上会议室":
router.push("/MeetingRoom");
case "研判首页":
router.push("/ResearchHome");
break;
case "后台":
router.push("/editPassword");