From c41deb1af25d73c49f981463ce9f71b2088a1e92 Mon Sep 17 00:00:00 2001 From: nick-delirium Date: Tue, 3 Dec 2024 11:03:58 +0100 Subject: [PATCH] ui: check for metric type --- .../Dashboard/components/AddCardSection/AddCardSection.tsx | 3 +-- .../Dashboard/components/WidgetChart/WidgetChart.tsx | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/app/components/Dashboard/components/AddCardSection/AddCardSection.tsx b/frontend/app/components/Dashboard/components/AddCardSection/AddCardSection.tsx index 19a2973fb..ef71fccc0 100644 --- a/frontend/app/components/Dashboard/components/AddCardSection/AddCardSection.tsx +++ b/frontend/app/components/Dashboard/components/AddCardSection/AddCardSection.tsx @@ -135,11 +135,10 @@ function CategoryTab({ tab, inCards }: { tab: string, inCards?: boolean }) { const handleCardSelection = (card: string) => { metricStore.init(); const selectedCard = CARD_LIST.find((c) => c.key === card) as CardType; - const cardData: any = { metricType: selectedCard.cardType, name: selectedCard.title, - metricOf: selectedCard.metricOf + metricOf: selectedCard.metricOf, }; if (selectedCard.filters) { diff --git a/frontend/app/components/Dashboard/components/WidgetChart/WidgetChart.tsx b/frontend/app/components/Dashboard/components/WidgetChart/WidgetChart.tsx index cd8c1c28c..0645ab3ae 100644 --- a/frontend/app/components/Dashboard/components/WidgetChart/WidgetChart.tsx +++ b/frontend/app/components/Dashboard/components/WidgetChart/WidgetChart.tsx @@ -152,10 +152,11 @@ function WidgetChart(props: Props) { } prevMetricRef.current = metric; const timestmaps = drillDownPeriod.toTimestamps(); + const isTimeseries = metric.metricType === TIMESERIES; const payload = isSaved // TODO: remove after backend adds support for more view types - ? { ...metricParams, viewType: 'lineChart' } - : { ...params, ...timestmaps, ...metric.toJson(), viewType: 'lineChart' }; + ? { ...metricParams, viewType: isTimeseries ? 'lineChart' : metric.viewType } + : { ...params, ...timestmaps, ...metric.toJson(), viewType: isTimeseries ? 'lineChart' : metric.viewType }; debounceRequest( metric, payload,