diff --git a/apps/web/src/common/modules/widgets/_widgets/heatmap/Heatmap.vue b/apps/web/src/common/modules/widgets/_widgets/heatmap/Heatmap.vue index 601e0668de..13e5086d5d 100644 --- a/apps/web/src/common/modules/widgets/_widgets/heatmap/Heatmap.vue +++ b/apps/web/src/common/modules/widgets/_widgets/heatmap/Heatmap.vue @@ -67,7 +67,7 @@ const state = reactive({ isPrivateWidget: computed(() => props.widgetId.startsWith('private')), dataTable: undefined as PublicDataTableModel|PrivateDataTableModel|undefined, - data: null as Data | null, + data: computed(() => queryResult.data?.value ?? null), chart: null as EChartsType | null, xAxisData: computed(() => { if (!state.data?.results?.length) return []; @@ -193,19 +193,14 @@ const queryKey = computed(() => [ const queryResult = useQuery({ queryKey, - queryFn: async () => { - const results = await fetchWidgetData({ - widget_id: props.widgetId, - granularity: widgetOptionsState.granularityInfo?.granularity, - group_by: [widgetOptionsState.xAxisInfo?.data as string], - ...getWidgetLoadApiQueryDateRange(widgetOptionsState.granularityInfo?.granularity, dateRange.value), - ...(!isDateField(widgetOptionsState.xAxisInfo.data) && { page: { start: 1, limit: widgetOptionsState.xAxisInfo?.count } }), - vars: props.dashboardVars, - }); - state.data = results; - drawChart(state.data); - return results; - }, + queryFn: () => fetchWidgetData({ + widget_id: props.widgetId, + granularity: widgetOptionsState.granularityInfo?.granularity, + group_by: widgetOptionsState.xAxisInfo?.data ? [widgetOptionsState.xAxisInfo?.data] : [], + ...getWidgetLoadApiQueryDateRange(widgetOptionsState.granularityInfo?.granularity, dateRange.value), + ...(!isDateField(widgetOptionsState.xAxisInfo.data) && { page: { start: 0, limit: widgetOptionsState.xAxisInfo?.count } }), + vars: props.dashboardVars, + }), enabled: computed(() => props.widgetState !== 'INACTIVE' && !!state.dataTable && state.runQueries), staleTime: WIDGET_LOAD_STALE_TIME, }); @@ -242,6 +237,10 @@ watch([() => state.chartData, () => chartContext.value], ([, chartCtx]) => { } }); +watch(() => state.data, (newData) => { + drawChart(newData); +}); + const { widgetFrameProps, widgetFrameEventHandlers } = useWidgetFrame(props, emit, { dateRange, errorMessage: errorMessage.value, diff --git a/apps/web/src/common/modules/widgets/_widgets/line-chart/LineChart.vue b/apps/web/src/common/modules/widgets/_widgets/line-chart/LineChart.vue index f1671a4f02..7343c22a51 100644 --- a/apps/web/src/common/modules/widgets/_widgets/line-chart/LineChart.vue +++ b/apps/web/src/common/modules/widgets/_widgets/line-chart/LineChart.vue @@ -1,9 +1,10 @@