Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(hog-charts): clip y-axis at 0 when only an overlay dips negative (#57807)

Sam Penningtondb79154f88a6
diff --git a/frontend/src/lib/hog-charts/README.md b/frontend/src/lib/hog-charts/README.md
index 1f44bdc70239..5f7204c6ce75 100644
--- a/frontend/src/lib/hog-charts/README.md
+++ b/frontend/src/lib/hog-charts/README.md
@@ -76,17 +76,21 @@ kept for back-compat.
For custom tooltip content, pass a component to the `tooltip` prop. It receives
`TooltipContext` as props. Omit to use the built-in `DefaultTooltip`.
-### Series visibility flags
-
-All flags live under `series.visibility` and default to `false`.
-
-- `excluded`: fully excludes the series — no rendering, no scale contribution,
- no tooltip row, no hit-testing.
-- `fromTooltip`: the series still renders and participates in scales and
- hit-testing, but is omitted from `TooltipContext.seriesData` so it doesn't
- appear as a tooltip row. Useful for background/reference series that
- shouldn't clutter the tooltip.
-- `fromValueLabels`: the `ValueLabels` overlay skips this series.
-- `fromStack`: the series is excluded from d3 stack computation. Use for
- auxiliary overlays (trend lines, moving averages) that should not affect
- cumulative area heights.
+### Series role and visibility
+
+- `series.overlay` (default `false`): marks an auxiliary series derived from
+ primary data — trend lines and moving averages. Excluded from stack
+ computation and from the y-axis baseline calculation, so a trendline
+ projection won't drag the axis below 0 when the underlying data is
+ non-negative. (CI bands are not overlays — they represent real data
+ uncertainty whose range should still influence the axis.)
+
+The `series.visibility` object controls where a series appears:
+
+- `excluded` (default `false`): fully excludes the series — no rendering, no
+ scale contribution, no tooltip row, no hit-testing.
+- `tooltip` (default `true`): when `false`, the series still renders and
+ participates in scales and hit-testing, but is omitted from
+ `TooltipContext.seriesData` so it doesn't appear as a tooltip row.
+- `valueLabel` (default `true`): when `false`, the `ValueLabels` overlay
+ skips this series.
diff --git a/frontend/src/lib/hog-charts/charts/BarChart.test.tsx b/frontend/src/lib/hog-charts/charts/BarChart.test.tsx
index 6c579dbfa76e..636c1a88706b 100644
--- a/frontend/src/lib/hog-charts/charts/BarChart.test.tsx
+++ b/frontend/src/lib/hog-charts/charts/BarChart.test.tsx
@@ -202,10 +202,10 @@ describe('BarChart', () => {
expect(getHogChartTooltip()?.classList.contains('hog-charts-tooltip--pinned')).toBe(true)
})
- it('omits a series from tooltip when visibility.fromTooltip is true', async () => {
+ it('omits a series from tooltip when visibility.tooltip is false', async () => {
const series: Series[] = [
{ key: 'a', label: 'A', data: [10, 20, 30] },
- { key: 'b', label: 'B', data: [5, 15, 25], visibility: { fromTooltip: true } },
+ { key: 'b', label: 'B', data: [5, 15, 25], visibility: { tooltip: false } },
]
const { chart } = renderHogChart(<BarChart series={series} labels={LABELS} theme={THEME} />)
hoverAtIndex(chart.element, 1, LABELS.length)
diff --git a/frontend/src/lib/hog-charts/charts/LineChart.stories.tsx b/frontend/src/lib/hog-charts/charts/LineChart.stories.tsx
index c00b8057bbf5..70433b498813 100644
--- a/frontend/src/lib/hog-charts/charts/LineChart.stories.tsx
+++ b/frontend/src/lib/hog-charts/charts/LineChart.stories.tsx
@@ -147,7 +147,7 @@ export const HoveringInterior: Story = {
},
}
-/** Multi-series hover with one series hidden from the tooltip via `fromTooltip`. */
+/** Multi-series hover with one series hidden from the tooltip via `tooltip: false`. */
export const HoveringMultiSeries: Story = {
parameters: { layout: 'fullscreen' },
render: () => {
@@ -160,7 +160,8 @@ export const HoveringMultiSeries: Story = {
color: theme.colors[6],
data: DAYS.map(() => 30),
stroke: { pattern: [4, 4] },
- visibility: { fromTooltip: true, fromStack: true },
+ overlay: true,
+ visibility: { tooltip: false },
},
]
return (
@@ -189,11 +190,11 @@ export const VisibilityFlags: Story = {
const cases: { title: string; series: Series[] }[] = [
{ title: 'excluded', series: [base[0], { ...base[1], visibility: { excluded: true } }, base[2]] },
{
- title: 'fromValueLabels',
- series: [base[0], { ...base[1], visibility: { fromValueLabels: true } }, base[2]],
+ title: 'valueLabel: false',
+ series: [base[0], { ...base[1], visibility: { valueLabel: false } }, base[2]],
},
{
- title: 'fromStack (auxiliary)',
+ title: 'overlay (auxiliary)',
series: [
{ ...base[0], fill: { opacity: 0.5 } },
{ ...base[1], fill: { opacity: 0.5 } },
@@ -203,7 +204,7 @@ export const VisibilityFlags: Story = {
color: theme.colors[6],
data: [12, 18, 17, 25, 24, 33, 27],
stroke: { pattern: [4, 4] },
- visibility: { fromStack: true },
+ overlay: true,
},
],
},
@@ -240,7 +241,7 @@ export const CombinedOverlays: Story = {
color,
data: upper,
fill: { opacity: 0.2, lowerData: lower },
- visibility: { fromTooltip: true, fromValueLabels: true },
+ visibility: { tooltip: false, valueLabel: false },
},
{
key: 'visits__trend',
@@ -248,7 +249,8 @@ export const CombinedOverlays: Story = {
color,
data: trendLine(data),
stroke: { pattern: [1, 3] },
- visibility: { fromTooltip: true, fromValueLabels: true, fromStack: true },
+ overlay: true,
+ visibility: { tooltip: false, valueLabel: false },
},
]
return (
@@ -328,7 +330,7 @@ export const InProgressTail: Story = {
}
/** Hovers over the same composition as `CombinedOverlays`. Verifies the tooltip excludes
- * the banded fill and the dashed trend overlay (both `fromTooltip: true`) while the
+ * the banded fill and the dashed trend overlay (both `tooltip: false`) while the
* crosshair / highlight ring still fire on the main series. */
export const HoveringOverAuxSeries: Story = {
parameters: { layout: 'fullscreen' },
@@ -345,7 +347,7 @@ export const HoveringOverAuxSeries: Story = {
color,
data: upper,
fill: { opacity: 0.2, lowerData: lower },
- visibility: { fromTooltip: true, fromValueLabels: true },
+ visibility: { tooltip: false, valueLabel: false },
},
{
key: 'visits__trend',
@@ -353,7 +355,8 @@ export const HoveringOverAuxSeries: Story = {
color,
data: trendLine(data),
stroke: { pattern: [1, 3] },
- visibility: { fromTooltip: true, fromValueLabels: true, fromStack: true },
+ overlay: true,
+ visibility: { tooltip: false, valueLabel: false },
},
]
return (
@@ -379,7 +382,7 @@ export const HoveringOverAuxSeries: Story = {
throw new Error(`expected main series in tooltip, got: ${text}`)
}
if (text.includes('(CI)') || text.includes('(trend)')) {
- throw new Error(`fromTooltip aux series leaked into tooltip: ${text}`)
+ throw new Error(`aux series leaked into tooltip: ${text}`)
}
},
}
diff --git a/frontend/src/lib/hog-charts/charts/LineChart.test.tsx b/frontend/src/lib/hog-charts/charts/LineChart.test.tsx
index 8037fe717bdb..c463a784ddb9 100644
--- a/frontend/src/lib/hog-charts/charts/LineChart.test.tsx
+++ b/frontend/src/lib/hog-charts/charts/LineChart.test.tsx
@@ -187,10 +187,10 @@ describe('LineChart', () => {
expect(getHogChartTooltip()?.classList.contains('hog-charts-tooltip--pinned')).toBe(true)
})
- it('does not crash on hover for visibility.fromStack series', async () => {
+ it('does not crash on hover for overlay series', async () => {
const series: Series[] = [
{ key: 'a', label: 'A', data: [10, 20, 30] },
- { key: 'b', label: 'B', data: [5, 15, 25], visibility: { fromStack: true } },
+ { key: 'b', label: 'B', data: [5, 15, 25], overlay: true },
]
const { chart } = renderHogChart(<LineChart series={series} labels={LABELS} theme={THEME} />)
hoverAtIndex(chart.element, 1, LABELS.length)
@@ -198,10 +198,10 @@ describe('LineChart', () => {
expect(tooltip.textContent).toContain('Tue')
})
- it('omits a series from tooltip when visibility.fromTooltip is true', async () => {
+ it('omits a series from tooltip when visibility.tooltip is false', async () => {
const series: Series[] = [
{ key: 'a', label: 'A', data: [10, 20, 30] },
- { key: 'b', label: 'B', data: [5, 15, 25], visibility: { fromTooltip: true } },
+ { key: 'b', label: 'B', data: [5, 15, 25], visibility: { tooltip: false } },
]
const { chart } = renderHogChart(<LineChart series={series} labels={LABELS} theme={THEME} />)
hoverAtIndex(chart.element, 1, LABELS.length)
diff --git a/frontend/src/lib/hog-charts/charts/LineChart.tsx b/frontend/src/lib/hog-charts/charts/LineChart.tsx
index 9acc627bb9cd..2bff12476da5 100644
--- a/frontend/src/lib/hog-charts/charts/LineChart.tsx
+++ b/frontend/src/lib/hog-charts/charts/LineChart.tsx
@@ -161,6 +161,22 @@ function LineChartInner<Meta = unknown>({
drawGrid(baseDrawCtx, { gridColor: theme.gridColor })
}
+ // Clip data drawing to the plot area so an overlay series with values outside
+ // the y-domain (e.g. a trendline projecting below 0) doesn't bleed into the
+ // axis-label gutter beneath the chart. A small pad on top/bottom keeps strokes
+ // at the domain edge from rendering at half-thickness — line strokes and point
+ // markers extend past the value's pixel center.
+ const CLIP_PAD = 8
+ ctx.save()
+ ctx.beginPath()
+ ctx.rect(
+ dimensions.plotLeft,
+ dimensions.plotTop - CLIP_PAD,
+ dimensions.plotWidth,
+ dimensions.plotHeight + CLIP_PAD * 2
+ )
+ ctx.clip()
+
for (const s of coloredSeries) {
if (s.visibility?.excluded) {
continue
@@ -178,6 +194,8 @@ function LineChartInner<Meta = unknown>({
drawPoints(drawCtx, s, yValues)
}
}
+
+ ctx.restore()
},
[showGrid, stackedData]
)
@@ -198,7 +216,7 @@ function LineChartInner<Meta = unknown>({
// Auxiliary overlays (moving averages, trend lines) opt out of stacking.
// In percent-stack mode the y-scale domain is [0, 1], so mapping their raw
// values produces a highlight ring far outside the plot — skip them entirely.
- if (s.visibility?.fromStack) {
+ if (s.overlay) {
continue
}
const data = stackedData?.get(s.key)?.top ?? s.data
diff --git a/frontend/src/lib/hog-charts/charts/TimeSeriesLineChart/TimeSeriesLineChart.tsx b/frontend/src/lib/hog-charts/charts/TimeSeriesLineChart/TimeSeriesLineChart.tsx
index 48891f3015b9..1a619325e9a6 100644
--- a/frontend/src/lib/hog-charts/charts/TimeSeriesLineChart/TimeSeriesLineChart.tsx
+++ b/frontend/src/lib/hog-charts/charts/TimeSeriesLineChart/TimeSeriesLineChart.tsx
@@ -113,7 +113,7 @@ export function TimeSeriesLineChart<Meta = unknown>({
}
const allowed = new Set(seriesKeys)
return series.map((s) =>
- allowed.has(s.key) ? s : { ...s, visibility: { ...s.visibility, fromValueLabels: true } }
+ allowed.has(s.key) ? s : { ...s, visibility: { ...s.visibility, valueLabel: false } }
)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [series, seriesKeysSignature])
diff --git a/frontend/src/lib/hog-charts/charts/TimeSeriesLineChart/utils/derived-series.test.ts b/frontend/src/lib/hog-charts/charts/TimeSeriesLineChart/utils/derived-series.test.ts
index 1d21c9fb8702..da8a535626d8 100644
--- a/frontend/src/lib/hog-charts/charts/TimeSeriesLineChart/utils/derived-series.test.ts
+++ b/frontend/src/lib/hog-charts/charts/TimeSeriesLineChart/utils/derived-series.test.ts
@@ -29,8 +29,8 @@ describe('buildConfidenceIntervalSeries', () => {
expect(ci.meta).toEqual({ domain: 'visits' })
expect(ci.fill?.lowerData).toEqual([9, 11, 13, 15, 17, 19, 21])
expect(ci.fill?.opacity).toBeGreaterThan(0)
- expect(ci.visibility?.fromTooltip).toBe(true)
- expect(ci.visibility?.fromValueLabels).toBe(true)
+ expect(ci.visibility?.tooltip).toBe(false)
+ expect(ci.visibility?.valueLabel).toBe(false)
})
it('forwards the excluded flag so an excluded source hides the band', () => {
@@ -55,8 +55,8 @@ describe('buildMovingAverageSeries', () => {
expect(ma.color).toBe(SOURCE.color)
expect(ma.yAxisId).toBe(SOURCE.yAxisId)
expect(ma.stroke?.pattern).not.toBeUndefined()
- expect(ma.visibility?.fromStack).toBe(true)
- expect(ma.visibility?.fromTooltip).toBe(true)
+ expect(ma.overlay).toBe(true)
+ expect(ma.visibility?.tooltip).toBe(false)
})
it('uses an explicit label when provided', () => {
@@ -72,7 +72,7 @@ describe('buildTrendLineSeries', () => {
expect(tl.label).toBe('Visits')
expect(tl.color).toMatch(/^rgba\(/)
expect(tl.stroke?.pattern).toEqual([1, 3])
- expect(tl.visibility?.fromStack).toBe(true)
+ expect(tl.overlay).toBe(true)
})
it.each([
diff --git a/frontend/src/lib/hog-charts/charts/TimeSeriesLineChart/utils/derived-series.ts b/frontend/src/lib/hog-charts/charts/TimeSeriesLineChart/utils/derived-series.ts
index bb133c4a6317..a4ec48564b29 100644
--- a/frontend/src/lib/hog-charts/charts/TimeSeriesLineChart/utils/derived-series.ts
+++ b/frontend/src/lib/hog-charts/charts/TimeSeriesLineChart/utils/derived-series.ts
@@ -30,7 +30,7 @@ export function buildConfidenceIntervalSeries<Meta = unknown>(
yAxisId: input.yAxisId,
meta: input.meta,
fill: { opacity: CI_FILL_OPACITY, lowerData: input.lower },
- visibility: { excluded: input.excluded, fromTooltip: true, fromValueLabels: true },
+ visibility: { excluded: input.excluded, tooltip: false, valueLabel: false },
}
}
@@ -54,7 +54,8 @@ export function buildMovingAverageSeries<Meta = unknown>(input: BuildMovingAvera
yAxisId: sourceSeries.yAxisId,
meta: sourceSeries.meta,
stroke: { pattern: MA_DASH_PATTERN },
- visibility: { fromTooltip: true, fromStack: true },
+ overlay: true,
+ visibility: { tooltip: false },
}
}
@@ -86,7 +87,8 @@ export function buildTrendLineSeries<Meta = unknown>(input: BuildTrendLineSeries
yAxisId: sourceSeries.yAxisId,
meta: sourceSeries.meta,
stroke: { pattern: TREND_LINE_DASH_PATTERN },
- visibility: { fromTooltip: true, fromValueLabels: true, fromStack: true },
+ overlay: true,
+ visibility: { tooltip: false, valueLabel: false },
}
}
diff --git a/frontend/src/lib/hog-charts/core/interaction.test.ts b/frontend/src/lib/hog-charts/core/interaction.test.ts
index 959f65d7411e..ea2eb40acce5 100644
--- a/frontend/src/lib/hog-charts/core/interaction.test.ts
+++ b/frontend/src/lib/hog-charts/core/interaction.test.ts
@@ -152,12 +152,12 @@ describe('hog-charts interaction', () => {
expect(result?.seriesData[0].series.key).toBe('v')
})
- it('excludes visibility.fromTooltip series from seriesData but still uses their values for position.y', () => {
+ it('excludes visibility.tooltip:false series from seriesData but still uses their values for position.y', () => {
const shown = makeSeries({ key: 'shown', data: [10] })
- const hiddenFromTooltip = makeSeries({ key: 'hft', data: [50], visibility: { fromTooltip: true } })
+ const hiddenFromTooltip = makeSeries({ key: 'hft', data: [50], visibility: { tooltip: false } })
const alsoShown = makeSeries({ key: 'also', data: [20] })
// yScale: 10 -> 80, 20 -> 60, 50 -> 5. position.y is min(yPixels)
- // — if the visibility.fromTooltip series contributes, result is 5; otherwise 60.
+ // — if the tooltip:false series contributes, result is 5; otherwise 60.
const yScale = (v: number): number => ({ 10: 80, 20: 60, 50: 5 })[v] ?? 0
const result = buildTooltipContext(
0,
diff --git a/frontend/src/lib/hog-charts/core/interaction.ts b/frontend/src/lib/hog-charts/core/interaction.ts
index 6f388e4f9a76..7c62a9626afb 100644
--- a/frontend/src/lib/hog-charts/core/interaction.ts
+++ b/frontend/src/lib/hog-charts/core/interaction.ts
@@ -88,7 +88,7 @@ export function buildTooltipContext<Meta = unknown>(
continue
}
const value = resolveValue(s, dataIndex)
- if (!s.visibility?.fromTooltip) {
+ if (s.visibility?.tooltip !== false) {
seriesData.push({ series: s, value, color: s.color })
}
const seriesValueScale = yAxes?.[s.yAxisId ?? DEFAULT_Y_AXIS_ID]?.scale ?? yScale
diff --git a/frontend/src/lib/hog-charts/core/scales.test.ts b/frontend/src/lib/hog-charts/core/scales.test.ts
index 8c646c2d2ce7..26f90eabb487 100644
--- a/frontend/src/lib/hog-charts/core/scales.test.ts
+++ b/frontend/src/lib/hog-charts/core/scales.test.ts
@@ -100,6 +100,42 @@ describe('hog-charts scales', () => {
expect(domainMax).toBeLessThan(100)
})
+ it.each([
+ {
+ description: 'clips baseline to 0 when an overlay dips below 0 but primary data is non-negative',
+ primaryData: [0, 0, 5000, 14500],
+ overlayData: [-1000, 4000, 7000, 10000],
+ expectedMin: 0,
+ expectMaxAtLeast: undefined as number | undefined,
+ },
+ {
+ description: 'preserves negative axis when primary data has genuine negatives',
+ primaryData: [-50, 0, 100],
+ overlayData: [-10, 50, 110],
+ expectedMin: 'negative' as const,
+ expectMaxAtLeast: undefined,
+ },
+ {
+ description: 'lets overlay extend max even when baseline is clipped to 0',
+ primaryData: [0, 50, 100],
+ overlayData: [200, 250, 300],
+ expectedMin: 0,
+ expectMaxAtLeast: 300,
+ },
+ ])('$description', ({ primaryData, overlayData, expectedMin, expectMaxAtLeast }) => {
+ const main = makeSeries({ key: 'main', data: primaryData })
+ const trendline = makeSeries({ key: 'trend', data: overlayData, overlay: true })
+ const [domainMin, domainMax] = createYScale([main, trendline], dimensions).domain()
+ if (expectedMin === 'negative') {
+ expect(domainMin).toBeLessThan(0)
+ } else {
+ expect(domainMin).toBe(expectedMin)
+ }
+ if (expectMaxAtLeast !== undefined) {
+ expect(domainMax).toBeGreaterThanOrEqual(expectMaxAtLeast)
+ }
+ })
+
it('maps the output range from plotTop + plotHeight down to plotTop', () => {
const series = [makeSeries({ key: 's1', data: [0, 100] })]
const scale = createYScale(series, dimensions)
diff --git a/frontend/src/lib/hog-charts/core/scales.ts b/frontend/src/lib/hog-charts/core/scales.ts
index 7b48a63f192f..d3d43bfb331f 100644
--- a/frontend/src/lib/hog-charts/core/scales.ts
+++ b/frontend/src/lib/hog-charts/core/scales.ts
@@ -117,7 +117,12 @@ export function createYScale(
.clamp(true)
}
- if (min > 0) {
+ // Auxiliary overlays (trendline projections, moving averages) may dip below 0
+ // when the underlying data does not. They shouldn't drag the axis baseline below
+ // 0 — d3.nice() applied to a slightly-negative min produces a disproportionately
+ // large negative tick (e.g. [-1, 14500] → [-2000, 16000]).
+ const primaryRange = series.some((s) => s.overlay) ? seriesValueRange(series.filter((s) => !s.overlay)) : range
+ if (primaryRange.count > 0 && primaryRange.min >= 0) {
min = 0
} else if (max < 0) {
max = 0
@@ -184,9 +189,7 @@ function buildStackData(
labels: string[],
offset?: typeof d3.stackOffsetNone
): Map<string, StackedBand> {
- const visibleSeries = series.filter(
- (s) => !s.visibility?.excluded && !s.fill?.lowerData && !s.visibility?.fromStack
- )
+ const visibleSeries = series.filter((s) => !s.visibility?.excluded && !s.fill?.lowerData && !s.overlay)
if (visibleSeries.length === 0) {
return new Map()
}
diff --git a/frontend/src/lib/hog-charts/core/types.ts b/frontend/src/lib/hog-charts/core/types.ts
index 552d47f4bf5d..3384e25820dd 100644
--- a/frontend/src/lib/hog-charts/core/types.ts
+++ b/frontend/src/lib/hog-charts/core/types.ts
@@ -56,16 +56,20 @@ export interface Series<Meta = unknown> {
* filling down to the x-axis baseline. */
lowerData?: number[]
}
- /** Per-axis visibility flags. Each defaults to false (the series is included in everything). */
+ /** Auxiliary overlay derived from primary data — trend lines and moving averages.
+ * Excluded from stack computation and from the y-axis baseline calculation, so a
+ * trendline projection won't drag the axis below 0 when the underlying data is
+ * non-negative. (CI bands are not overlays — they represent real data uncertainty
+ * whose range should still influence the axis.) */
+ overlay?: boolean
+ /** Per-location visibility flags — control where this series appears. */
visibility?: {
/** Fully exclude the series — no rendering, no scale contribution, no tooltip, no hit-testing. */
excluded?: boolean
- /** Render and participate in scales/hit-testing, but omit from tooltip seriesData. */
- fromTooltip?: boolean
- /** ValueLabels overlay skips this series. */
- fromValueLabels?: boolean
- /** Excluded from d3 stack computation (auxiliary overlays like trend lines / moving averages). */
- fromStack?: boolean
+ /** Whether the series appears in the tooltip's seriesData. Defaults to true. */
+ tooltip?: boolean
+ /** Whether the ValueLabels overlay draws a label for this series. Defaults to true. */
+ valueLabel?: boolean
}
}
diff --git a/frontend/src/lib/hog-charts/overlays/ValueLabels.stories.tsx b/frontend/src/lib/hog-charts/overlays/ValueLabels.stories.tsx
index 7766e2018bb2..0f61fa415154 100644
--- a/frontend/src/lib/hog-charts/overlays/ValueLabels.stories.tsx
+++ b/frontend/src/lib/hog-charts/overlays/ValueLabels.stories.tsx
@@ -120,7 +120,8 @@ export const HiddenOnAuxiliarySeries: Story = {
color,
data: [22, 30, 38, 46, 54, 62, 70],
stroke: { pattern: [1, 3] },
- visibility: { fromTooltip: true, fromValueLabels: true },
+ overlay: true,
+ visibility: { tooltip: false, valueLabel: false },
}
return (
<Stage>
diff --git a/frontend/src/lib/hog-charts/overlays/ValueLabels.test.tsx b/frontend/src/lib/hog-charts/overlays/ValueLabels.test.tsx
index 975931b93e3a..2f5721c2f215 100644
--- a/frontend/src/lib/hog-charts/overlays/ValueLabels.test.tsx
+++ b/frontend/src/lib/hog-charts/overlays/ValueLabels.test.tsx
@@ -243,7 +243,7 @@ describe('ValueLabels', () => {
const series: ResolvedSeries[] = [
{ key: 'a', label: 'A', color: '#112233', data: [10, 0, 30] },
{ key: 'b', label: 'B', color: '#445566', data: [5, 0, 5] },
- { key: 'c', label: 'C', color: '#778899', data: [99, 99, 99], visibility: { fromValueLabels: true } },
+ { key: 'c', label: 'C', color: '#778899', data: [99, 99, 99], visibility: { valueLabel: false } },
]
const ctx = makeContext(series, { labels: ['Mon', 'Tue', 'Wed'] })
const divs = labelDivs(renderInChart(ctx, <ValueLabels mode="stack-total" />).container)
diff --git a/frontend/src/lib/hog-charts/overlays/ValueLabels.tsx b/frontend/src/lib/hog-charts/overlays/ValueLabels.tsx
index 79bbad651f94..da152ec846c4 100644
--- a/frontend/src/lib/hog-charts/overlays/ValueLabels.tsx
+++ b/frontend/src/lib/hog-charts/overlays/ValueLabels.tsx
@@ -119,7 +119,7 @@ function buildStackTotal(args: BuildCandidatesArgs, ctx: CanvasRenderingContext2
if (isPercent) {
return out
}
- const visible = series.filter((s) => !s.visibility?.excluded && !s.visibility?.fromValueLabels)
+ const visible = series.filter((s) => !s.visibility?.excluded && s.visibility?.valueLabel !== false)
if (visible.length === 0) {
return out
}
@@ -159,7 +159,7 @@ function buildPerSegment(args: BuildCandidatesArgs, ctx: CanvasRenderingContext2
for (let sIdx = 0; sIdx < series.length; sIdx++) {
const s = series[sIdx]
- if (s.visibility?.excluded || s.visibility?.fromValueLabels) {
+ if (s.visibility?.excluded || s.visibility?.valueLabel === false) {
continue
}
const yScale = resolveYScale(s, scales)