104 lines
2.4 KiB
Vue
104 lines
2.4 KiB
Vue
<script setup lang="ts">
|
|
import { ref } from 'vue';
|
|
import { useEcharts } from '@/hooks/common/echarts';
|
|
|
|
defineOptions({
|
|
name: 'RingChart'
|
|
});
|
|
|
|
const props = defineProps<{ data: { name: string; highRisk: number; middleRisk: number }[]; colors: string[] }>();
|
|
|
|
const { domRef, updateOptions } = useEcharts(() => ({
|
|
tooltip: {
|
|
trigger: "axis",
|
|
axisPointer: {
|
|
type: "shadow",
|
|
textStyle: {
|
|
color: "#fff",
|
|
},
|
|
},
|
|
},
|
|
legend: {
|
|
bottom: '20%',
|
|
left: 'center',
|
|
icon: 'circle',
|
|
itemWidth: 10,
|
|
itemHeight: 10,
|
|
itemStyle: {
|
|
borderWidth: 0
|
|
},
|
|
},
|
|
grid: {
|
|
top: "10%",
|
|
left: "5%",
|
|
right: "5%",
|
|
bottom: "35%",
|
|
},
|
|
calculable: true,
|
|
xAxis: [
|
|
{
|
|
type: "category",
|
|
boundaryGap: true, // 新增,固定柱子位置
|
|
axisLine: {
|
|
show: false,
|
|
},
|
|
axisLabel: {
|
|
interval: 0,
|
|
},
|
|
splitLine: { show: false },
|
|
axisTick: { show: false },
|
|
splitArea: { show: false },
|
|
data: [] as string[],
|
|
},
|
|
],
|
|
yAxis: [
|
|
{
|
|
type: "value",
|
|
show: false,
|
|
},
|
|
],
|
|
series: [
|
|
{
|
|
name: "高风险项",
|
|
stack: "总数",
|
|
type: "bar",
|
|
barWidth: 30,
|
|
barGap: "10%",
|
|
color: "#00B42A",
|
|
data: [] as number[],
|
|
},
|
|
// 中风险项 - 橙色
|
|
{
|
|
name: "中风险项",
|
|
stack: "总数",
|
|
type: "bar",
|
|
barWidth: 30,
|
|
color: "#FF7D00",
|
|
data: [] as number[],
|
|
},
|
|
]
|
|
}));
|
|
|
|
function init() {
|
|
updateOptions(opts => {
|
|
let allMonth = props.data.map((item:any) => item.name);
|
|
let highRis = props.data.map((item:any) => item.highRisk);
|
|
let middleRisk = props.data.map((item:any) => item.middleRisk);
|
|
opts.xAxis[0].data = allMonth;
|
|
opts.series[0].data = highRis;
|
|
opts.series[1].data = middleRisk;
|
|
opts.series[0].color = props.colors[0];
|
|
opts.series[1].color = props.colors[1];
|
|
return opts;
|
|
});
|
|
}
|
|
|
|
init();
|
|
</script>
|
|
|
|
<template>
|
|
<div ref="domRef" class="w-full h-220px overflow-hidden"></div>
|
|
</template>
|
|
|
|
<style scoped></style>
|