diff --git a/src/components/Graph.vue b/src/components/Graph.vue index 85638baa..dc6be903 100644 --- a/src/components/Graph.vue +++ b/src/components/Graph.vue @@ -46,8 +46,12 @@ const props = defineProps({ }, filters: { type: Object as PropType<{ - value: number | string; - dataIndex: number; + duration: { + startTime: string; + endTime: string; + }; + isRange: boolean; + dataIndex?: number; sourceId: string; }>, }, @@ -110,9 +114,39 @@ watch( return; } if (props.filters) { + if (props.filters.isRange) { + const markArea = { + silent: true, + itemStyle: { + opacity: 0.3, + }, + data: [ + [ + { + xAxis: props.filters.duration.startTime, + }, + { + xAxis: props.filters.duration.endTime, + }, + ], + ], + }; + const series = props.option.series; + for (const [key, temp] of series.entries()) { + if (key === 0) { + temp.markArea = markArea; + } + } + const options = { + ...props.option, + series, + }; + setOptions(options); + return; + } instance.dispatchAction({ type: "showTip", - dataIndex: props.filters.dataIndex, + dataIndex: props.filters.dataIndex || undefined, seriesIndex: 0, }); } diff --git a/src/utils/echarts.ts b/src/utils/echarts.ts index 59fc2874..db786a00 100644 --- a/src/utils/echarts.ts +++ b/src/utils/echarts.ts @@ -26,6 +26,7 @@ import { DataZoomComponent, VisualMapComponent, TimelineComponent, + MarkAreaComponent, } from "echarts/components"; import { SVGRenderer } from "echarts/renderers"; @@ -43,6 +44,7 @@ echarts.use([ DataZoomComponent, VisualMapComponent, TimelineComponent, + MarkAreaComponent, ]); export default echarts; diff --git a/src/views/dashboard/configuration/Event.vue b/src/views/dashboard/configuration/Event.vue index cdc9ddab..a5d9b661 100644 --- a/src/views/dashboard/configuration/Event.vue +++ b/src/views/dashboard/configuration/Event.vue @@ -20,6 +20,14 @@ limitations under the License. --> @change="updateConfig" /> + diff --git a/src/views/dashboard/graphs/Line.vue b/src/views/dashboard/graphs/Line.vue index 02cdf90a..286a633f 100644 --- a/src/views/dashboard/graphs/Line.vue +++ b/src/views/dashboard/graphs/Line.vue @@ -33,9 +33,13 @@ const props = defineProps({ type: Object as PropType< LineConfig & { filters: { - value: number | string; - dataIndex: number; sourceId: string; + duration: { + startTime: string; + endTime: string; + }; + isRange: boolean; + dataIndex?: number; }; } & { id: string } >, diff --git a/src/views/dashboard/related/event/Content.vue b/src/views/dashboard/related/event/Content.vue index 5343c7f2..be557389 100644 --- a/src/views/dashboard/related/event/Content.vue +++ b/src/views/dashboard/related/event/Content.vue @@ -112,16 +112,11 @@ function visTimeline() { } ); const index = properties.items[0]; - const i = items[index]; + const i = events[index - 1 || 0]; + for (const widget of widgets) { - const startTime: string = dateFormatTime( - new Date(i.startTime), - appStore.duration.step - ); - const endTime: string = dateFormatTime( - new Date(i.endTime), - appStore.duration.step - ); + const startTime = dateFormatTime(i.start, appStore.duration.step); + const endTime = dateFormatTime(i.end, appStore.duration.step); widget.filters = { sourceId: dashboardStore.selectedGrid.id || "", isRange: true,