gtsoft-snail-job-admin/src/views/home/modules/card-retry-chart.vue

81 lines
1.4 KiB
Vue
Raw Normal View History

2024-03-25 09:41:48 +08:00
<script setup lang="ts">
2024-03-26 11:47:11 +08:00
import { useEcharts } from '@/hooks/common/echarts';
2024-03-25 09:41:48 +08:00
defineOptions({
name: 'CardRetryChart'
});
interface Props {
modelValue: Api.Dashboard.RetryTaskBarList[];
}
const props = defineProps<Props>();
const { domRef, updateOptions } = useEcharts(() => ({
tooltip: {
trigger: 'axis',
appendToBody: true,
confine: true,
axisPointer: {
type: 'shadow'
}
},
grid: {
top: '21px',
height: '40px',
containLabel: true
},
xAxis: {
// @ts-expect-error 忽略EChart
axisLine: false,
type: 'category',
data: [] as string[],
axisTick: {
alignWithLabel: true
}
},
yAxis: {
type: 'value',
// @ts-expect-error 忽略EChart
axisLine: false,
scale: true,
show: false
},
series: [
{
name: 'Task Count',
type: 'bar',
barWidth: '60%',
data: [] as number[]
}
]
}));
2024-04-13 01:23:58 +08:00
const getData = async () => {
2024-03-25 09:41:48 +08:00
await new Promise(resolve => {
2024-03-28 16:22:18 +08:00
setTimeout(resolve, 1);
2024-03-25 09:41:48 +08:00
});
if (!props.modelValue) {
2024-04-13 01:23:58 +08:00
await getData();
2024-03-25 09:41:48 +08:00
return;
}
updateOptions(opts => {
// @ts-expect-error 忽略EChart
opts.xAxis.data = props.modelValue!.map(item => item.x);
// @ts-expect-error 忽略EChart
opts.series[0].data = props.modelValue!.map(item => item.taskTotal);
return opts;
});
2024-04-13 01:23:58 +08:00
};
2024-03-25 09:41:48 +08:00
2024-04-13 01:23:58 +08:00
getData();
2024-03-25 09:41:48 +08:00
</script>
<template>
<div ref="domRef" class="h-42px overflow-hidden"></div>
</template>
<style scoped></style>