区域停留分布
-
diff --git a/apps/web-antd/src/views/ops/trajectory/modules/trend-chart.vue b/apps/web-antd/src/views/ops/trajectory/modules/trend-chart.vue
index ac1940132..b4e1e4344 100644
--- a/apps/web-antd/src/views/ops/trajectory/modules/trend-chart.vue
+++ b/apps/web-antd/src/views/ops/trajectory/modules/trend-chart.vue
@@ -8,46 +8,32 @@ import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
import { Empty } from 'ant-design-vue';
const props = defineProps<{
- records: OpsTrajectoryApi.TrajectoryRecord[];
+ data: OpsTrajectoryApi.HourlyTrend[];
}>();
const chartRef = ref();
const { renderEcharts } = useEcharts(chartRef);
-/** 按小时聚合进出次数 */
-const hourlyData = computed(() => {
+const hasData = computed(() => props.data.length > 0);
+
+function getChartOptions(): any {
+ // 补全 0-23 小时
const hours: string[] = [];
const enterCounts: number[] = [];
const leaveCounts: number[] = [];
- // 生成 0-23 小时
+ const dataMap = new Map
();
+ for (const item of props.data) {
+ dataMap.set(item.hour, item);
+ }
+
for (let i = 0; i < 24; i++) {
hours.push(`${String(i).padStart(2, '0')}:00`);
- enterCounts.push(0);
- leaveCounts.push(0);
+ const item = dataMap.get(i);
+ enterCounts.push(item?.enterCount ?? 0);
+ leaveCounts.push(item?.leaveCount ?? 0);
}
- for (const record of props.records) {
- // 统计进入
- if (record.enterTime) {
- const h = new Date(record.enterTime).getHours();
- enterCounts[h]!++;
- }
- // 统计离开
- if (record.leaveTime) {
- const h = new Date(record.leaveTime).getHours();
- leaveCounts[h]!++;
- }
- }
-
- return { hours, enterCounts, leaveCounts };
-});
-
-const hasData = computed(() => props.records.length > 0);
-
-function getChartOptions(): any {
- const { hours, enterCounts, leaveCounts } = hourlyData.value;
-
return {
tooltip: { trigger: 'axis' },
legend: {
@@ -90,8 +76,8 @@ function getChartOptions(): any {
symbol: 'circle',
symbolSize: 5,
data: enterCounts,
- lineStyle: { width: 2.5, color: '#52c41a' },
- itemStyle: { color: '#52c41a' },
+ lineStyle: { width: 2.5, color: '#1677ff' },
+ itemStyle: { color: '#1677ff' },
areaStyle: {
opacity: 0.12,
color: {
@@ -101,8 +87,8 @@ function getChartOptions(): any {
x2: 0,
y2: 1,
colorStops: [
- { offset: 0, color: 'rgba(82, 196, 26, 0.3)' },
- { offset: 1, color: 'rgba(82, 196, 26, 0.02)' },
+ { offset: 0, color: 'rgba(22, 119, 255, 0.3)' },
+ { offset: 1, color: 'rgba(22, 119, 255, 0.02)' },
],
},
},
@@ -114,8 +100,8 @@ function getChartOptions(): any {
symbol: 'circle',
symbolSize: 5,
data: leaveCounts,
- lineStyle: { width: 2.5, color: '#ff4d4f' },
- itemStyle: { color: '#ff4d4f' },
+ lineStyle: { width: 2.5, color: '#fa8c16' },
+ itemStyle: { color: '#fa8c16' },
areaStyle: {
opacity: 0.12,
color: {
@@ -125,8 +111,8 @@ function getChartOptions(): any {
x2: 0,
y2: 1,
colorStops: [
- { offset: 0, color: 'rgba(255, 77, 79, 0.3)' },
- { offset: 1, color: 'rgba(255, 77, 79, 0.02)' },
+ { offset: 0, color: 'rgba(250, 140, 22, 0.3)' },
+ { offset: 1, color: 'rgba(250, 140, 22, 0.02)' },
],
},
},
@@ -136,7 +122,7 @@ function getChartOptions(): any {
}
watch(
- () => props.records,
+ () => props.data,
() => {
if (hasData.value) {
renderEcharts(getChartOptions());
@@ -147,21 +133,18 @@ watch(
-