: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(insights): port stickiness bar to hog-charts (#60130)
Sam Pennington540ffca15ead
diff --git a/frontend/src/scenes/trends/Trends.tsx b/frontend/src/scenes/trends/Trends.tsxindex 5eb628052c54..01343fced0fd 100644--- a/frontend/src/scenes/trends/Trends.tsx+++ b/frontend/src/scenes/trends/Trends.tsx@@ -39,6 +39,11 @@ const StickinessLineChart = lazy(() =>default: m.StickinessLineChart,})))+const StickinessBarChart = lazy(() =>+ import('products/product_analytics/frontend/insights/trends/StickinessBarChart/StickinessBarChart').then((m) => ({+ default: m.StickinessBarChart,+ }))+)const TrendsPieChart = lazy(() =>import('products/product_analytics/frontend/insights/trends/TrendsPieChart/TrendsPieChart').then((m) => ({default: m.TrendsPieChart,@@ -105,6 +110,9 @@ export function TrendInsight({ view, context, embedded, inSharedMode, editMode }if (hogChartsTrendsEnabled) {return <TrendsBarChart context={context} inSharedMode={inSharedMode} />}+ if (hogChartsStickinessEnabled) {+ return <StickinessBarChart context={context} />+ }return <ActionsLineGraph {...commonProps} />}if (display === ChartDisplayType.BoldNumber) {diff --git a/products/product_analytics/frontend/insights/trends/StickinessBarChart/StickinessBarChart.test.tsx b/products/product_analytics/frontend/insights/trends/StickinessBarChart/StickinessBarChart.test.tsxnew file mode 100644index 000000000000..c65990317903--- /dev/null+++ b/products/product_analytics/frontend/insights/trends/StickinessBarChart/StickinessBarChart.test.tsx@@ -0,0 +1,125 @@+import '@testing-library/jest-dom'++import { cleanup, screen, waitFor } from '@testing-library/react'++import { FEATURE_FLAGS } from 'lib/constants'+import { setupJsdom, setupSyncRaf } from 'lib/hog-charts/testing'++import { NodeKind } from '~/queries/schema/schema-general'+import { buildStickinessQuery, chart, getHogChart, personsModal, renderInsight } from '~/test/insight-testing'+import { ChartDisplayType } from '~/types'++let cleanupJsdom: () => void+let cleanupRaf: () => void++beforeEach(() => {+ cleanupJsdom = setupJsdom()+ cleanupRaf = setupSyncRaf()+})++afterEach(() => {+ personsModal.cleanupAll()+ cleanupRaf()+ cleanupJsdom()+ cleanup()+})++const HOG_CHARTS_FLAG = { [FEATURE_FLAGS.PRODUCT_ANALYTICS_HOG_CHARTS_STICKINESS]: true }+const stickinessBar = (extra?: Parameters<typeof buildStickinessQuery>[0]): ReturnType<typeof buildStickinessQuery> =>+ buildStickinessQuery({ stickinessFilter: { display: ChartDisplayType.ActionsBar }, ...extra })++describe('StickinessBarChart', () => {+ it.each([+ { display: ChartDisplayType.ActionsBar, layout: 'stacked' },+ { display: ChartDisplayType.ActionsUnstackedBar, layout: 'grouped' },+ ])('renders a $layout bar chart from a StickinessQuery', async ({ display }) => {+ renderInsight({+ query: stickinessBar({ stickinessFilter: { display } }),+ featureFlags: HOG_CHARTS_FLAG,+ })++ await waitFor(() => {+ expect(screen.getByTestId('stickiness-bar-graph')).toBeInTheDocument()+ })+ })++ it('renders one series per event', async () => {+ renderInsight({+ query: stickinessBar({+ series: [+ { kind: NodeKind.EventsNode, event: '$pageview', name: '$pageview' },+ { kind: NodeKind.EventsNode, event: 'Napped', name: 'Napped' },+ ],+ }),+ featureFlags: HOG_CHARTS_FLAG,+ })++ await waitFor(() => {+ expect(screen.getByRole('img', { name: /chart with 2 data series/i })).toBeInTheDocument()+ })+ })++ it('y-axis: renders percent ticks (legacy `${value.toFixed(1)}%` parity)', async () => {+ renderInsight({ query: stickinessBar(), featureFlags: HOG_CHARTS_FLAG })++ await screen.findByRole('img', { name: /chart with/i })+ const ticks = getHogChart().yTicks()+ expect(ticks.length).toBeGreaterThan(0)+ expect(ticks.every((t) => /%/.test(t))).toBe(true)+ })++ it('tooltip: percent value + "stickiness on {interval} {day}" title (not a calendar date)', async () => {+ renderInsight({ query: stickinessBar(), featureFlags: HOG_CHARTS_FLAG })++ const tooltip = await chart.hoverTooltip(2)+ // Days are 1-indexed in the mock, so bucket 2 == day 3.+ expect(tooltip.row('Pageview')).toMatch(/%/)+ expect(tooltip.title()).toMatch(/stickiness on day 3/i)+ // Must NOT default to a Unix-epoch-derived calendar date.+ expect(tooltip.title()).not.toMatch(/1970/i)+ })++ it('renders InsightEmptyState when all series are zero', async () => {+ renderInsight({+ query: stickinessBar({+ series: [{ kind: NodeKind.EventsNode, event: 'NoActivity', name: 'NoActivity' }],+ }),+ featureFlags: HOG_CHARTS_FLAG,+ })++ await waitFor(() => {+ expect(screen.getByTestId('insight-empty-state')).toBeInTheDocument()+ })+ expect(screen.queryByRole('img', { name: /chart with/i })).not.toBeInTheDocument()+ })++ it('click → persons modal: opens with a "stickiness on {interval} {day}" title', async () => {+ renderInsight({ query: stickinessBar(), featureFlags: HOG_CHARTS_FLAG })++ await chart.clickAtIndex(2)++ await waitFor(() => {+ expect(personsModal.get()).toBeInTheDocument()+ })+ expect(personsModal.title()).toMatch(/stickiness on day 3/i)+ expect(personsModal.title()).toMatch(/Pageview/i)+ })++ it('click → context.onDataPointClick fires with the integer day instead of opening the modal', async () => {+ const onDataPointClick = jest.fn()+ renderInsight({+ query: stickinessBar(),+ context: { onDataPointClick },+ featureFlags: HOG_CHARTS_FLAG,+ })++ await chart.clickAtIndex(2)++ await waitFor(() => {+ expect(onDataPointClick).toHaveBeenCalledTimes(1)+ })+ const [seriesArg] = onDataPointClick.mock.calls[0]+ expect(seriesArg.day).toBe(3)+ expect(personsModal.get()).not.toBeInTheDocument()+ })+})diff --git a/products/product_analytics/frontend/insights/trends/StickinessBarChart/StickinessBarChart.tsx b/products/product_analytics/frontend/insights/trends/StickinessBarChart/StickinessBarChart.tsxnew file mode 100644index 000000000000..e3a0d38b3db6--- /dev/null+++ b/products/product_analytics/frontend/insights/trends/StickinessBarChart/StickinessBarChart.tsx@@ -0,0 +1,178 @@+import { useValues } from 'kea'+import { useCallback, useMemo } from 'react'++import { buildTheme } from 'lib/charts/utils/theme'+import { TimeSeriesBarChart } from 'lib/hog-charts'+import type { PointClickData, Series, TimeSeriesBarChartConfig, TooltipContext } from 'lib/hog-charts'+import { InsightEmptyState } from 'scenes/insights/EmptyStates'+import { insightLogic } from 'scenes/insights/insightLogic'+import type { SeriesDatum } from 'scenes/insights/InsightTooltip/insightTooltipUtils'+import { teamLogic } from 'scenes/teamLogic'+import { openPersonsModal } from 'scenes/trends/persons-modal/PersonsModal'+import { trendsDataLogic } from 'scenes/trends/trendsDataLogic'+import type { IndexedTrendResult } from 'scenes/trends/types'++import { groupsModel } from '~/models/groupsModel'+import { InsightVizNode } from '~/queries/schema/schema-general'+import { QueryContext } from '~/queries/types'+import { ChartDisplayType } from '~/types'++import { makeChartErrorHandler } from '../shared/chartErrorHandler'+import { buildTrendsSeriesMeta, resolveGroupTypeLabel, type TrendsSeriesMeta } from '../shared/trendsSeriesMeta'+import { TrendsTooltip } from '../shared/TrendsTooltip'+import { handleStickinessChartClick } from '../StickinessLineChart/handleStickinessChartClick'+import {+ buildStickinessLabels,+ buildStickinessTooltipTitle,+ stickinessPercentFormatter,+ STICKINESS_TOOLTIP_CONFIG,+} from '../StickinessLineChart/stickinessChartTransforms'+import { buildStickinessBarSeries, buildStickinessBarTimeSeriesConfig } from './stickinessBarChartTransforms'++interface StickinessBarChartProps {+ context?: QueryContext<InsightVizNode>+}++const handleChartError = makeChartErrorHandler('stickiness-bar-chart')++export function StickinessBarChart({ context }: StickinessBarChartProps): JSX.Element | null {+ const theme = useMemo(() => buildTheme(), [])+ const { insightProps } = useValues(insightLogic)++ const {+ indexedResults,+ display,+ interval,+ yAxisScaleType,+ getTrendsColor,+ getTrendsHidden,+ currentPeriodResult,+ breakdownFilter,+ trendsFilter,+ formula,+ labelGroupType,+ hasPersonsModal,+ querySource,+ showValuesOnSeries,+ } = useValues(trendsDataLogic(insightProps))+ const { timezone, baseCurrency } = useValues(teamLogic)+ const { aggregationLabel } = useValues(groupsModel)++ // Inverted polarity vs legacy `isStacked` in `ActionsLineGraph`; matches `TrendsBarChart`.+ const isGrouped = display === ChartDisplayType.ActionsUnstackedBar++ const resolvedGroupTypeLabel = context?.groupTypeLabel ?? resolveGroupTypeLabel(labelGroupType, aggregationLabel)++ const bucketCount = currentPeriodResult?.labels?.length ?? 0+ const labels = useMemo(() => buildStickinessLabels(bucketCount, interval), [bucketCount, interval])++ const hasData = (indexedResults ?? []).some((r: IndexedTrendResult) => r.count !== 0)++ // `TimeSeriesBarChart` has a single y-axis — `showMultipleYAxes` is intentionally not forwarded.+ const series: Series<TrendsSeriesMeta>[] = useMemo(+ () =>+ buildStickinessBarSeries<IndexedTrendResult, TrendsSeriesMeta>(indexedResults ?? [], {+ getColor: getTrendsColor,+ getHidden: getTrendsHidden,+ buildMeta: buildTrendsSeriesMeta,+ }),+ [indexedResults, getTrendsColor, getTrendsHidden]+ )++ const chartConfig: TimeSeriesBarChartConfig = useMemo(+ () =>+ buildStickinessBarTimeSeriesConfig({+ yAxisScaleType,+ isGrouped,+ valueLabels: showValuesOnSeries ? { formatter: stickinessPercentFormatter } : false,+ tooltip: STICKINESS_TOOLTIP_CONFIG,+ }),+ [yAxisScaleType, isGrouped, showValuesOnSeries]+ )++ // Close over the primitives so the click memos don't invalidate when unrelated+ // context fields change. `openPersonsModal` is a stable module import.+ const onDataPointClick = context?.onDataPointClick+ const formatCompareLabel = context?.formatCompareLabel+ const hasClickHandler = !!onDataPointClick || !!hasPersonsModal++ const clickDeps = useMemo(+ () => ({+ context: onDataPointClick ? { onDataPointClick } : undefined,+ hasPersonsModal: !!hasPersonsModal,+ interval,+ querySource,+ indexedResults: indexedResults ?? [],+ openPersonsModal,+ }),+ [onDataPointClick, hasPersonsModal, interval, querySource, indexedResults]+ )++ const onPointClick = useCallback(+ (clickData: PointClickData) => {+ handleStickinessChartClick(clickData.series.key, clickData.dataIndex, clickDeps)+ },+ [clickDeps]+ )++ const altTitle = useMemo(() => buildStickinessTooltipTitle(interval), [interval])++ const renderTooltip = useCallback(+ (ctx: TooltipContext<TrendsSeriesMeta>) => {+ const onRowClick = hasClickHandler+ ? (datum: SeriesDatum) => {+ const seriesKey = ctx.seriesData[datum.datasetIndex].series.key+ handleStickinessChartClick(seriesKey, datum.dataIndex, clickDeps)+ }+ : undefined+ return (+ <TrendsTooltip+ context={ctx}+ timezone={timezone}+ interval={interval ?? undefined}+ breakdownFilter={breakdownFilter ?? undefined}+ trendsFilter={trendsFilter}+ formula={formula}+ showPercentView={true}+ isPercentStackView={false}+ baseCurrency={baseCurrency}+ groupTypeLabel={resolvedGroupTypeLabel}+ formatCompareLabel={formatCompareLabel}+ onRowClick={onRowClick}+ altTitle={altTitle}+ />+ )+ },+ [+ timezone,+ interval,+ breakdownFilter,+ trendsFilter,+ formula,+ baseCurrency,+ resolvedGroupTypeLabel,+ formatCompareLabel,+ hasClickHandler,+ clickDeps,+ altTitle,+ ]+ )++ if (!hasData) {+ return <InsightEmptyState heading={context?.emptyStateHeading} detail={context?.emptyStateDetail} />+ }++ return (+ <TimeSeriesBarChart<TrendsSeriesMeta>+ series={series}+ labels={labels}+ theme={theme}+ config={chartConfig}+ tooltip={renderTooltip}+ onPointClick={hasClickHandler ? onPointClick : undefined}+ className="BarGraph"+ dataAttr="stickiness-bar-graph"+ onError={handleChartError}+ />+ )+}diff --git a/products/product_analytics/frontend/insights/trends/StickinessBarChart/stickinessBarChartTransforms.test.ts b/products/product_analytics/frontend/insights/trends/StickinessBarChart/stickinessBarChartTransforms.test.tsnew file mode 100644index 000000000000..fc34c94b793b--- /dev/null+++ b/products/product_analytics/frontend/insights/trends/StickinessBarChart/stickinessBarChartTransforms.test.ts@@ -0,0 +1,38 @@+import type { TooltipConfig } from 'lib/hog-charts'++import { buildStickinessBarTimeSeriesConfig } from './stickinessBarChartTransforms'++// `buildStickinessBarSeries` is a re-export of the line port's `buildStickinessSeries` —+// covered in `../StickinessLineChart/stickinessChartTransforms.test.ts`. The yAxis builder+// is covered there too; the tests below stick to bar-specific behavior.++describe('buildStickinessBarTimeSeriesConfig', () => {+ it.each([+ { isGrouped: false, expected: 'stacked' as const },+ { isGrouped: true, expected: 'grouped' as const },+ ])('maps isGrouped=$isGrouped to barLayout=$expected', ({ isGrouped, expected }) => {+ expect(buildStickinessBarTimeSeriesConfig({ isGrouped }).barLayout).toBe(expected)+ })++ it('omits the xAxis date config (labels are pre-formatted interval counts)', () => {+ expect(buildStickinessBarTimeSeriesConfig({ isGrouped: false }).xAxis).toBeUndefined()+ })++ it('delegates the yAxis to the shared stickiness builder (percent + scale + grid)', () => {+ const cfg = buildStickinessBarTimeSeriesConfig({ isGrouped: false, yAxisScaleType: 'log10' })+ expect(cfg.yAxis!.scale).toBe('log')+ expect(cfg.yAxis!.tickFormatter!(50)).toBe('50.0%')+ })++ it('passes through valueLabels and tooltip', () => {+ const formatter = (v: number): string => `${v}!`+ const tooltip: TooltipConfig = { pinnable: true, placement: 'top' }+ const cfg = buildStickinessBarTimeSeriesConfig({+ isGrouped: false,+ valueLabels: { formatter },+ tooltip,+ })+ expect(cfg.valueLabels).toEqual({ formatter })+ expect(cfg.tooltip).toBe(tooltip)+ })+})diff --git a/products/product_analytics/frontend/insights/trends/StickinessBarChart/stickinessBarChartTransforms.ts b/products/product_analytics/frontend/insights/trends/StickinessBarChart/stickinessBarChartTransforms.tsnew file mode 100644index 000000000000..0bdbd0d0c88d--- /dev/null+++ b/products/product_analytics/frontend/insights/trends/StickinessBarChart/stickinessBarChartTransforms.ts@@ -0,0 +1,30 @@+import type { TimeSeriesBarChartConfig, TooltipConfig } from 'lib/hog-charts'++import {+ buildStickinessSeries,+ buildStickinessYAxisConfig,+ type StickinessYAxisScaleType,+} from '../StickinessLineChart/stickinessChartTransforms'++export { buildStickinessSeries as buildStickinessBarSeries }++export interface BuildStickinessBarTimeSeriesConfigOpts {+ yAxisScaleType?: StickinessYAxisScaleType+ /** ActionsBar → stacked; ActionsUnstackedBar → grouped. */+ isGrouped: boolean+ showGrid?: boolean+ valueLabels?: TimeSeriesBarChartConfig['valueLabels']+ tooltip?: TooltipConfig+}++export function buildStickinessBarTimeSeriesConfig(+ opts: BuildStickinessBarTimeSeriesConfigOpts+): TimeSeriesBarChartConfig {+ // No xAxis date config — labels are pre-formatted interval counts (Day 0, Day 1, …).+ return {+ yAxis: buildStickinessYAxisConfig({ yAxisScaleType: opts.yAxisScaleType, showGrid: opts.showGrid }),+ valueLabels: opts.valueLabels,+ barLayout: opts.isGrouped ? 'grouped' : 'stacked',+ tooltip: opts.tooltip,+ }+}diff --git a/products/product_analytics/frontend/insights/trends/StickinessLineChart/StickinessLineChart.tsx b/products/product_analytics/frontend/insights/trends/StickinessLineChart/StickinessLineChart.tsxindex af64262d0b26..5d8fb5645676 100644--- a/products/product_analytics/frontend/insights/trends/StickinessLineChart/StickinessLineChart.tsx+++ b/products/product_analytics/frontend/insights/trends/StickinessLineChart/StickinessLineChart.tsx@@ -1,10 +1,9 @@import { useValues } from 'kea'-import posthog from 'posthog-js'-import { useCallback, useMemo, type ErrorInfo } from 'react'+import { useCallback, useMemo } from 'react'import { buildTheme } from 'lib/charts/utils/theme'import { TimeSeriesLineChart } from 'lib/hog-charts'-import type { PointClickData, Series, TimeSeriesLineChartConfig, TooltipConfig, TooltipContext } from 'lib/hog-charts'+import type { PointClickData, Series, TimeSeriesLineChartConfig, TooltipContext } from 'lib/hog-charts'import { InsightEmptyState } from 'scenes/insights/EmptyStates'import { insightLogic } from 'scenes/insights/insightLogic'import type { SeriesDatum } from 'scenes/insights/InsightTooltip/insightTooltipUtils'@@ -13,47 +12,31 @@ import { openPersonsModal } from 'scenes/trends/persons-modal/PersonsModal'import { trendsDataLogic } from 'scenes/trends/trendsDataLogic'import type { IndexedTrendResult } from 'scenes/trends/types'-import { themeLogic } from '~/layout/navigation-3000/themeLogic'import { groupsModel } from '~/models/groupsModel'import { InsightVizNode } from '~/queries/schema/schema-general'import { QueryContext } from '~/queries/types'-import { resolveGroupTypeLabel, type TrendsSeriesMeta } from '../shared/trendsSeriesMeta'+import { makeChartErrorHandler } from '../shared/chartErrorHandler'+import { buildTrendsSeriesMeta, resolveGroupTypeLabel, type TrendsSeriesMeta } from '../shared/trendsSeriesMeta'import { TrendsTooltip } from '../shared/TrendsTooltip'import { handleStickinessChartClick } from './handleStickinessChartClick'import {buildStickinessLabels,buildStickinessLineTimeSeriesConfig,buildStickinessSeries,+ buildStickinessTooltipTitle,stickinessPercentFormatter,+ STICKINESS_TOOLTIP_CONFIG,} from './stickinessChartTransforms'interface StickinessLineChartProps {context?: QueryContext<InsightVizNode>}-const TOOLTIP_CONFIG: TooltipConfig = { pinnable: true, placement: 'top' }--const handleChartError = (error: Error, info: ErrorInfo): void => {- posthog.captureException(error, {- feature: 'stickiness-line-chart',- componentStack: info.componentStack ?? undefined,- })-}--/** Stickiness `date` is an interval-count integer (1, 2, …), not a date.- * Render "stickiness on {interval} {day}" so InsightTooltip doesn't try to- * format it as a calendar date (which would land on 1970-01-01). */-function buildStickinessAltTitle(interval: string | null | undefined): (seriesData: SeriesDatum[]) => string {- return (seriesData) => {- const day = seriesData[0]?.date_label ?? ''- return `stickiness on ${interval || 'day'} ${day}`- }-}+const handleChartError = makeChartErrorHandler('stickiness-line-chart')export function StickinessLineChart({ context }: StickinessLineChartProps): JSX.Element | null {- const { isDarkModeOn } = useValues(themeLogic)- const theme = useMemo(() => buildTheme(), [isDarkModeOn])+ const theme = useMemo(() => buildTheme(), [])const { insightProps } = useValues(insightLogic)const {@@ -91,14 +74,7 @@ export function StickinessLineChart({ context }: StickinessLineChartProps): JSX.showMultipleYAxes: showMultipleYAxes ?? undefined,getColor: getTrendsColor,getHidden: getTrendsHidden,- buildMeta: (rr) => ({- action: rr.action,- breakdown_value: rr.breakdown_value,- compare_label: rr.compare_label,- days: rr.days,- order: rr.action?.order ?? rr.id,- filter: rr.filter,- }),+ buildMeta: buildTrendsSeriesMeta,}),[indexedResults, getTrendsColor, getTrendsHidden, showMultipleYAxes])@@ -109,7 +85,7 @@ export function StickinessLineChart({ context }: StickinessLineChartProps): JSX.yAxisScaleType,valueLabels: showValuesOnSeries ? { formatter: stickinessPercentFormatter } : false,showCrosshair: true,- tooltip: TOOLTIP_CONFIG,+ tooltip: STICKINESS_TOOLTIP_CONFIG,}),[yAxisScaleType, showValuesOnSeries])@@ -135,7 +111,7 @@ export function StickinessLineChart({ context }: StickinessLineChartProps): JSX.[clickDeps])- const altTitle = useMemo(() => buildStickinessAltTitle(interval), [interval])+ const altTitle = useMemo(() => buildStickinessTooltipTitle(interval), [interval])const renderTooltip = useCallback((ctx: TooltipContext<TrendsSeriesMeta>) => {diff --git a/products/product_analytics/frontend/insights/trends/StickinessLineChart/stickinessChartTransforms.ts b/products/product_analytics/frontend/insights/trends/StickinessLineChart/stickinessChartTransforms.tsindex c28800f27ffe..9ea93e7d4417 100644--- a/products/product_analytics/frontend/insights/trends/StickinessLineChart/stickinessChartTransforms.ts+++ b/products/product_analytics/frontend/insights/trends/StickinessLineChart/stickinessChartTransforms.ts@@ -1,5 +1,6 @@import { DEFAULT_Y_AXIS_ID } from 'lib/hog-charts'import type { Series, TimeSeriesLineChartConfig, TooltipConfig, YAxisConfig } from 'lib/hog-charts'+import type { SeriesDatum } from 'scenes/insights/InsightTooltip/insightTooltipUtils'// Shape both IndexedTrendResult (kea) and StickinessResultItem (MCP) satisfy.export interface StickinessResultLike {@@ -13,6 +14,11 @@ export interface StickinessResultLike {filter?: unknown}+/** Stickiness y-axis scale options. Upstream (`trendsDataLogic`) exposes this as a+ * loose `string | undefined`, so we keep that shape at the API boundary; only the+ * literal `'log10'` is branched on inside `buildStickinessYAxisConfig`. */+export type StickinessYAxisScaleType = string | null | undefined+export interface BuildStickinessSeriesOpts<R extends StickinessResultLike, M = unknown> {showMultipleYAxes?: booleangetColor: (r: R, index: number) => string@@ -69,8 +75,36 @@ export function stickinessPercentFormatter(value: number): string {return `${value.toFixed(1)}%`}+/** Stickiness adapters pin their tooltip to the top with pinnable rows. Shared so the+ * line and bar ports stay consistent. */+export const STICKINESS_TOOLTIP_CONFIG: TooltipConfig = { pinnable: true, placement: 'top' }++/** Stickiness `date` is an interval-count integer (1, 2, …), not a date.+ * Render "stickiness on {interval} {day}" so InsightTooltip doesn't try to+ * format it as a calendar date (which would land on 1970-01-01). */+export function buildStickinessTooltipTitle(+ interval: string | null | undefined+): (seriesData: SeriesDatum[]) => string {+ return (seriesData) => {+ const day = seriesData[0]?.date_label ?? ''+ return `stickiness on ${interval || 'day'} ${day}`+ }+}++/** Shared stickiness y-axis: percent tick formatter + linear/log scale toggle. */+export function buildStickinessYAxisConfig(opts: {+ yAxisScaleType?: StickinessYAxisScaleType+ showGrid?: boolean+}): YAxisConfig {+ return {+ scale: opts.yAxisScaleType === 'log10' ? 'log' : 'linear',+ showGrid: opts.showGrid ?? true,+ tickFormatter: stickinessPercentFormatter,+ }+}+export interface BuildStickinessLineTimeSeriesConfigOpts {- yAxisScaleType?: string | null+ yAxisScaleType?: StickinessYAxisScaleTypeshowGrid?: booleanvalueLabels?: TimeSeriesLineChartConfig['valueLabels']showCrosshair?: boolean@@ -80,14 +114,9 @@ export interface BuildStickinessLineTimeSeriesConfigOpts {export function buildStickinessLineTimeSeriesConfig(opts: BuildStickinessLineTimeSeriesConfigOpts): TimeSeriesLineChartConfig {- const yAxis: YAxisConfig = {- scale: opts.yAxisScaleType === 'log10' ? 'log' : 'linear',- showGrid: opts.showGrid ?? true,- tickFormatter: stickinessPercentFormatter,- }return {// No xAxis date config — labels are pre-formatted interval counts (Day 0, Day 1, …).- yAxis,+ yAxis: buildStickinessYAxisConfig({ yAxisScaleType: opts.yAxisScaleType, showGrid: opts.showGrid }),valueLabels: opts.valueLabels,showCrosshair: opts.showCrosshair,tooltip: opts.tooltip,