Skip to content

Commit 1d5cdfd

Browse files
committed
fix(webapp): hide the cap line when the chart is filtered or isolated
The cap applies to the whole metric, so drawing it against a filtered slice or an isolated breakdown series is misleading — and the full cap dwarfs the slice, squishing its data flat. Hide the cap line whenever the chart is scoped to a slice.
1 parent b87d57b commit 1d5cdfd

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

packages/webapp/src/components/patterns/chart/ChartCard.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ export const ChartCard: React.FC<ChartCardProps> = ({
118118
// response's top-level total); otherwise the single series' total. `effectiveEmpty` (not
119119
// `isEmpty`) so a breakdown with empty top-level `usage` still shows a number.
120120
const visibleKeys = (breakdownSeries ?? []).filter((s) => !interactions.isSeriesHidden(s.key)).map((s) => s.key);
121+
// The cap applies to the whole metric, so hide the cap line whenever the chart is scoped to a
122+
// slice — a filter, or an isolated/hidden breakdown series — otherwise the full cap dwarfs the
123+
// slice and squishes its data flat.
124+
const isSliced = Boolean(filtered) || (isBreakdown && visibleKeys.length < (breakdownSeries?.length ?? 0));
121125
let headlineTotal: number | undefined;
122126
if (effectiveEmpty) {
123127
headlineTotal = undefined;
@@ -200,7 +204,7 @@ export const ChartCard: React.FC<ChartCardProps> = ({
200204
interactions={interactions}
201205
// Cap line only on the cumulative/point-in-time (area) view; on daily bars the
202206
// monthly cap dwarfs the per-day values and would flatten the bars.
203-
capLine={renderAsArea ? capLine : undefined}
207+
capLine={renderAsArea && !isSliced ? capLine : undefined}
204208
/>
205209
{breakdownSeries && breakdownSeries.length > 0 && <ChartLegend series={breakdownSeries} interactions={interactions} />}
206210
{!isBreakdown && singleSeries && (

0 commit comments

Comments
 (0)