From fc69e5c50f6445715e8d4dcda3b50b3863b4ea74 Mon Sep 17 00:00:00 2001 From: jacovinus Date: Wed, 27 Sep 2023 20:27:47 +0200 Subject: [PATCH] fix: error messages for custom queries --- packages/main/plugins/Cardinality/Chart.tsx | 6 +-- .../main/plugins/Cardinality/ChartsGroup.tsx | 4 ++ .../main/plugins/Cardinality/Configurator.tsx | 26 ++++++++-- .../Cardinality/api/CardinalityRequest.tsx | 47 +++++++++++++++++-- .../Cardinality/api/useCardinalityData.tsx | 6 --- .../Cardinality/store/CardinalityStore.tsx | 16 ++++--- .../plugins/Cardinality/useConfigurator.tsx | 17 +++---- 7 files changed, 91 insertions(+), 31 deletions(-) diff --git a/packages/main/plugins/Cardinality/Chart.tsx b/packages/main/plugins/Cardinality/Chart.tsx index f7bc2ee0..3e93e866 100644 --- a/packages/main/plugins/Cardinality/Chart.tsx +++ b/packages/main/plugins/Cardinality/Chart.tsx @@ -28,10 +28,8 @@ const CardinalityChart = forwardRef( setWidth(ref?.current?.offsetWidth - 8); } }, [ref?.current]); - const chartRenderer = (isChartGroup, chartData) => { if (chartData && isChartGroup && chart !== "") { - console.log(chartData?.valueTypesMapped[chart]?.names); return ( ); - } else { - return ( + } else if (chartData && !isChartGroup) { + return ( { + const xAxisData = rows?.map((row) => row.name); const valueData = rows?.map((row) => row.value); const diffData = rows?.map((row) => @@ -95,6 +96,9 @@ export const useChartData = (rows: SeriesRowProps[]) => { export const ChartsGroup: React.FC = ({ rows, theme }) => { const chartData = useChartData(rows); + + if(rows.length === 0) return null + return ( {chartData?.valueTypes[0] !== undefined ? ( diff --git a/packages/main/plugins/Cardinality/Configurator.tsx b/packages/main/plugins/Cardinality/Configurator.tsx index 841bf38a..7bfac4f2 100644 --- a/packages/main/plugins/Cardinality/Configurator.tsx +++ b/packages/main/plugins/Cardinality/Configurator.tsx @@ -8,7 +8,7 @@ import useConfigurator from "./useConfigurator"; import CardinalityInput from "./CardinalityInput"; import { ConfigContainerStyles } from "./ConfigContainerStyles"; import { useCardinalityRequest } from "./api/CardinalityRequest"; - +import useCardinalityStore from "./store/CardinalityStore"; type ConfiguratorProps = { theme: any; percent?: number; @@ -45,15 +45,23 @@ const Configurator: React.FC = ({ limit, totalSeries, reset, + date, } = useConfigurator({ setHistoryItem }); //a handler for making a get request to the api const { handleCardinalityRequest } = useCardinalityRequest(true); - + const { setTimeSeriesSelector, setFocusLabel, setLimitEntries } = + useCardinalityStore(); const handleReset = () => { reset(); - handleCardinalityRequest(); + + handleCardinalityRequest({ + match: "", + focusLabel: "", + topN: limit, + date, + }); }; // this feature is not implemented yet @@ -142,7 +150,17 @@ const Configurator: React.FC = ({ Reset