From 3139f8b11333de6f2217b5e7554a413fcaedeb32 Mon Sep 17 00:00:00 2001 From: Adrian Mroz Date: Wed, 16 Mar 2022 14:27:58 +0100 Subject: [PATCH] Show NoData card on BarChart when no split datums came from Druid --- .../bar-chart/improved-bar-chart/bar-chart.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/client/visualizations/bar-chart/improved-bar-chart/bar-chart.tsx b/src/client/visualizations/bar-chart/improved-bar-chart/bar-chart.tsx index 1b8486eb3..63efad50f 100644 --- a/src/client/visualizations/bar-chart/improved-bar-chart/bar-chart.tsx +++ b/src/client/visualizations/bar-chart/improved-bar-chart/bar-chart.tsx @@ -21,6 +21,7 @@ import { Essence } from "../../../../common/models/essence/essence"; import { FilterClause } from "../../../../common/models/filter-clause/filter-clause"; import { Stage } from "../../../../common/models/stage/stage"; import { Binary, Nullary } from "../../../../common/utils/functional/functional"; +import { MessageCard } from "../../../components/message-card/message-card"; import { Scroller } from "../../../components/scroller/scroller"; import { SPLIT } from "../../../config/constants"; import { selectMainDatum } from "../../../utils/dataset/selectors/selectors"; @@ -49,9 +50,14 @@ interface BarChartProps { export const BarChart: React.FunctionComponent = props => { const { dataset, essence, stage, highlight, acceptHighlight, dropHighlight, saveHighlight } = props; - const { [SPLIT]: split, ...totals } = selectMainDatum(dataset); const model = create(essence, dataset); + const transposedDataset = transposeDataset(dataset, model); + if (transposedDataset.length === 0) { + return ; + } + + const { [SPLIT]: split, ...totals } = selectMainDatum(dataset); const data = isStacked(model) ? stackDataset(transposedDataset, model) : transposedDataset; const seriesCount = model.series.count(); const domain = getXDomain(data, model);