数通互联化工云平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

146 lines
2.8 KiB

<!--
@ 作者: 秦东
@ 时间: 2023-06-30 16:03:33
@ 备注: 行政组织离职率
-->
4 months ago
<script lang="ts" setup>
import * as echarts from "echarts";
import { zexianStrcut } from "@/api/displayboardapi/types";
import { getDimissionRate } from "@/api/displayboardapi/indexapi";
4 months ago
const legendList = new Array();
const seriesData = new Array();
const props = defineProps({
id: {
type: String,
4 months ago
default: "barChart",
},
className: {
type: String,
4 months ago
default: "",
},
width: {
type: String,
4 months ago
default: "100%",
required: true,
},
height: {
type: String,
4 months ago
default: "650px",
required: true,
},
title: {
type: String,
4 months ago
default: "",
},
});
const option = {
title: {
show: false,
4 months ago
text: "离职率(%)",
},
tooltip: {
4 months ago
trigger: "axis",
},
legend: {
4 months ago
right: "10",
data: legendList,
4 months ago
orient: "vertical",
top: "50",
4 months ago
type: "scroll",
icon: "circle",
itemWidth: 10,
4 months ago
itemHeight: 10,
},
grid: {
4 months ago
left: "20px",
right: "290px",
bottom: "1%",
containLabel: true,
},
toolbox: {
4 months ago
right: "20px",
top: "0",
feature: {
saveAsImage: {
4 months ago
title: "导出图片",
iconStyle: {
borderWidth: 1,
4 months ago
borderType: "solid",
},
},
},
},
xAxis: {
4 months ago
type: "category",
boundaryGap: false,
4 months ago
data: [
"1月",
"2月",
"3月",
"4月",
"5月",
"6月",
"7月",
"8月",
"9月",
"10月",
"11月",
"12月",
],
},
yAxis: {
4 months ago
type: "value",
splitLine: {
show: true,
lineStyle: {
4 months ago
type: "dotted",
},
},
},
4 months ago
series: seriesData,
};
onMounted(() => {
getDimissionRate()
.then((data: any) => {
// console.log(data,data.data.list);
if (data.code == 0) {
4 months ago
data.data.list.forEach((item: { orgname: any; odds: any }) => {
legendList.push(item.orgname);
seriesData.push({
name: item.orgname,
4 months ago
type: "line",
smooth: true,
data: item.odds,
label: {
4 months ago
show: true,
},
});
});
}
})
.finally(() => {
// console.log("legendList--->",legendList)
// 图表初始化
4 months ago
const chart = echarts.init(document.getElementById(props.id) as HTMLDivElement);
chart.setOption(option);
// 大小自适应
4 months ago
window.addEventListener("resize", () => {
chart.resize();
});
4 months ago
});
});
</script>
<template>
<el-card shadow="never" class="w-full">
4 months ago
<div class="glm-title" v-if="!!title">
<span class="bt">{{ title }}</span>
</div>
<div :id="id" :class="className" :style="{ height, width }" />
</el-card>
</template>
4 months ago
<style lang="scss" scoped></style>