: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(experiments): render the variant timeseries chart with quill charts (#81708)
Sam Pennington46a99a82f1e5
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 26bf76ff9433..44a77af22e82 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -2100,6 +2100,14 @@ snapshots:hash: v1.k794b7964.d59e36f12a812ad81bfe87a667bac644ccd806ec7ef08bba8406c56c4c384275.UiTTwDxfntJBUdYNxiPU-1zQWfGwMIfxVvEy97dhcskerrortracking-volumesparkline--events-before-data-range--light:hash: v1.k794b7964.124227295a3079c9a271b5b1b1de997d8f1a9b536928ac8fc0e5e806afd2f8f5.9CCTbFhZMpAVVger6Xuyp0kXNjRjdlk9vf1PwtmZEZw+ experiments-varianttimeseriestooltip--pending-day--dark:+ hash: v1.k794b7964.97727c0656cd286fbe329fe68ea8b0b635911b169247a8b45ecc5a6571563509.V2WbyXdFPiGIw4bJpjP7eoK2QZW4iqJo9w68-A_60wM+ experiments-varianttimeseriestooltip--pending-day--light:+ hash: v1.k794b7964.afd712c02b718cfbd1b35f3966fe63a2699b9e3d465cbc5ed710b89d2d73e9d5.-XPnMS-DF1sjI1LEQNueLTaiaSauWbdDzdhIlF_M59I+ experiments-varianttimeseriestooltip--significant-day--dark:+ hash: v1.k794b7964.454a2741f9e14479f4e7d044cfc853cccf980bc479ebd99d8582c028b1a26f3b.19bCdMNg7cR3OObP_ntNQ0FSRQc9WENqcMT1uMErFss+ experiments-varianttimeseriestooltip--significant-day--light:+ hash: v1.k794b7964.6e850075cec396cda57b4d44acd24b1fb4deb1e00c640db0049d172e8d99f2bb.Im0tdmWO-QcJ_sukw7HEC5eSF0ZBsTJgYvKKf-KxnLAexporter-funnels--funnel-time-to-convert-insight--dark:hash: v1.k794b7964.32e0fdd763e52aa74a859cc74be91c34aa9bc415f698cd276a1cbf5165e07e96.83HRBJWS8NFTguzPf-6KQ58qPcfF8byzAZ6DrhaMS4Mexporter-funnels--funnel-time-to-convert-insight--light:diff --git a/frontend/src/scenes/experiments/MetricsView/new/VariantTimeseriesChart.tsx b/frontend/src/scenes/experiments/MetricsView/new/VariantTimeseriesChart.tsxindex 2adee1760f99..1d91106ef25c 100644--- a/frontend/src/scenes/experiments/MetricsView/new/VariantTimeseriesChart.tsx+++ b/frontend/src/scenes/experiments/MetricsView/new/VariantTimeseriesChart.tsx@@ -1,11 +1,17 @@-import { useChart } from 'lib/hooks/useChart'-import { useInsightTooltip } from 'scenes/insights/useInsightTooltip'+import { useValues } from 'kea'+import { useMemo } from 'react'-import { ProcessedChartData } from '../../experimentTimeseriesLogic'+import { TimeSeriesLineChart, type TimeSeriesLineChartConfig } from '@posthog/quill-charts'++import { useChartConfig, useChartTheme } from 'lib/charts/hooks'+import { teamLogic } from 'scenes/teamLogic'++import type { ProcessedChartData } from '../../experimentTimeseriesLogic'import { useChartColors } from '../shared/colors'import { VariantTimeseriesTooltip } from './VariantTimeseriesTooltip'+import { DELTA_SERIES_KEY, buildVariantTimeseriesSeries } from './variantTimeseriesTransforms'-interface VariantTimeseriesChartProps {+export interface VariantTimeseriesChartProps {chartData: ProcessedChartDataisRatioMetric?: boolean}@@ -14,132 +20,58 @@ export function VariantTimeseriesChart({chartData: data,isRatioMetric = false,}: VariantTimeseriesChartProps): JSX.Element {+ const { timezone } = useValues(teamLogic)+ const theme = useChartTheme()const colors = useChartColors()- const { getTooltip, showTooltip, hideTooltip, positionTooltip } = useInsightTooltip()-- const { canvasRef } = useChart<'line'>({- getConfig: () => {- if (!data) {- return null- }-- const { labels, datasets, processedData, computedAt } = data-- return {- type: 'line' as const,- data: { labels, datasets },- options: {- responsive: true,- maintainAspectRatio: false,- interaction: {- intersect: false,- mode: 'nearest',- axis: 'x',- },- scales: {- y: {- grid: {- display: true,- color: (context) => {- if (context.tick.value === 0) {- return colors.ZERO_LINE- }- return colors.EXPOSURES_AXIS_LINES- },- lineWidth: (context) => {- if (context.tick.value === 0) {- return 1.25- }- return 1- },- },- ticks: {- callback: (value) => {- const num = Number(value)- return `${(num * 100).toFixed(0)}%`- },- },- afterBuildTicks: (axis) => {- const ticks = axis.ticks.map((t) => t.value)- if (!ticks.includes(0)) {- axis.ticks.push({ value: 0 })- axis.ticks.sort((a, b) => a.value - b.value)- }- // When 0 is the lowest tick, pad below so it doesn't- // overlap with x-axis date labels- if (axis.ticks.length > 1 && axis.ticks[0].value === 0) {- const tickStep = axis.ticks[1].value - axis.ticks[0].value- axis.min = -tickStep * 0.3- }- },- },- x: {- grid: {- display: false,- },- ticks: {- maxRotation: 45,- minRotation: 45,- },- },- },- plugins: {- legend: {- display: false,- },- tooltip: {- enabled: false,- external: ({ chart, tooltip }) => {- const canvas = chart.canvas- if (!canvas) {- return- }- const [tooltipRoot, tooltipEl] = getTooltip()+ const { labels, processedData, computedAt, variantColor } = data- if (tooltip.opacity === 0 || !tooltip.dataPoints?.length) {- hideTooltip()- return- }-- const dataIndex = tooltip.dataPoints[0].dataIndex- const dataPoint = processedData[dataIndex]- if (!dataPoint) {- hideTooltip()- return- }-- showTooltip()- tooltipRoot.render(- <VariantTimeseriesTooltip- date={dataPoint.date}- delta={dataPoint.value}- lowerBound={dataPoint.lower_bound}- upperBound={dataPoint.upper_bound}- isRatioMetric={isRatioMetric}- exposures={dataPoint.number_of_samples}- denominator={dataPoint.denominator_sum}- significant={dataPoint.significant}- hasRealData={dataPoint.hasRealData}- computedAt={computedAt}- />- )+ const { series, lowerBounds, upperBounds } = useMemo(+ () => buildVariantTimeseriesSeries(processedData, variantColor),+ [processedData, variantColor]+ )- const bounds = canvas.getBoundingClientRect()- positionTooltip(tooltipEl, bounds, tooltip.caretX, 0, false)- },- },- crosshair: false,- },- },- }- },- deps: [data, colors.EXPOSURES_AXIS_LINES, colors.ZERO_LINE, isRatioMetric],- })+ const config = useChartConfig<TimeSeriesLineChartConfig>(+ () => ({+ xAxis: { interval: 'day', timezone },+ yAxis: { format: 'percentage_scaled', decimalPlaces: 0 },+ confidenceIntervals: [{ seriesKey: DELTA_SERIES_KEY, lower: lowerBounds, upper: upperBounds }],+ // A goal line rather than an overlay child: it also stretches the axis so zero stays+ // on-plot when every delta sits on one side of it.+ goalLines: [{ value: 0, displayLabel: false, color: colors.ZERO_LINE }],+ }),+ [timezone, lowerBounds, upperBounds, colors.ZERO_LINE]+ )return (- <div className="relative h-[224px]">- <canvas ref={canvasRef} />+ <div className="relative h-[224px] flex flex-col">+ <TimeSeriesLineChart+ series={series}+ labels={labels}+ theme={theme}+ config={config}+ tooltip={({ dataIndex }) => {+ const point = processedData[dataIndex]+ if (!point) {+ return null+ }+ return (+ <VariantTimeseriesTooltip+ date={point.date}+ delta={point.value}+ lowerBound={point.lower_bound}+ upperBound={point.upper_bound}+ isRatioMetric={isRatioMetric}+ exposures={point.number_of_samples}+ denominator={point.denominator_sum}+ significant={point.significant}+ hasRealData={point.hasRealData}+ computedAt={computedAt}+ color={variantColor}+ />+ )+ }}+ /></div>)}diff --git a/frontend/src/scenes/experiments/MetricsView/new/VariantTimeseriesTooltip.stories.tsx b/frontend/src/scenes/experiments/MetricsView/new/VariantTimeseriesTooltip.stories.tsxnew file mode 100644index 000000000000..a8711406e072--- /dev/null+++ b/frontend/src/scenes/experiments/MetricsView/new/VariantTimeseriesTooltip.stories.tsx@@ -0,0 +1,64 @@+import type { Meta, StoryObj } from '@storybook/react'++import { Stage, playHoverAtFraction } from '@posthog/quill-charts/story-helpers'++import type { ProcessedChartData, ProcessedTimeseriesDataPoint } from '../../experimentTimeseriesLogic'+import { VariantTimeseriesChart } from './VariantTimeseriesChart'+import { VariantTimeseriesTooltip } from './VariantTimeseriesTooltip'++const DAYS = ['2026-06-01', '2026-06-02', '2026-06-03', '2026-06-04', '2026-06-05']+const DELTAS = [0.012, 0.028, 0.041, 0.06, 0.06]+const LOWER = [-0.004, 0.008, 0.019, 0.032, 0.032]+const UPPER = [0.028, 0.048, 0.063, 0.088, 0.088]+const COMPUTED_AT = '2026-06-05T09:30:00Z'+const HAS_REAL_DATA_ALL = [true, true, true, true, true]+const HAS_REAL_DATA_PENDING_TAIL = [true, false, false, false, false]++function buildChartData(hasRealData: boolean[]): ProcessedChartData {+ const processedData: ProcessedTimeseriesDataPoint[] = DAYS.map((date, i) => ({+ date,+ value: DELTAS[i],+ lower_bound: LOWER[i],+ upper_bound: UPPER[i],+ hasRealData: hasRealData[i],+ number_of_samples: 1200 + i * 300,+ denominator_sum: 18200 + i * 900,+ significant: true,+ }))+ return {+ labels: DAYS,+ processedData,+ computedAt: COMPUTED_AT,+ variantColor: '#1d4aff',+ }+}++function TooltipChart({ hasRealData = HAS_REAL_DATA_ALL }: { hasRealData?: boolean[] }): JSX.Element {+ return (+ <Stage width={620}>+ <VariantTimeseriesChart chartData={buildChartData(hasRealData)} />+ </Stage>+ )+}++const meta: Meta<typeof VariantTimeseriesTooltip> = {+ title: 'Experiments/VariantTimeseriesTooltip',+ component: VariantTimeseriesTooltip,+ parameters: {+ layout: 'centered',+ testOptions: { snapshotBrowsers: ['chromium'] },+ },+}+export default meta++type Story = StoryObj<typeof VariantTimeseriesTooltip>++export const SignificantDay: Story = {+ render: () => <TooltipChart />,+ play: async ({ canvasElement }) => await playHoverAtFraction(canvasElement, 0.4),+}++export const PendingDay: Story = {+ render: () => <TooltipChart hasRealData={HAS_REAL_DATA_PENDING_TAIL} />,+ play: async ({ canvasElement }) => await playHoverAtFraction(canvasElement, 0.4),+}diff --git a/frontend/src/scenes/experiments/MetricsView/new/VariantTimeseriesTooltip.tsx b/frontend/src/scenes/experiments/MetricsView/new/VariantTimeseriesTooltip.tsxindex 72c110719e03..ec08c0532a83 100644--- a/frontend/src/scenes/experiments/MetricsView/new/VariantTimeseriesTooltip.tsx+++ b/frontend/src/scenes/experiments/MetricsView/new/VariantTimeseriesTooltip.tsx@@ -1,6 +1,7 @@import { useValues } from 'kea'-import { IconCalendar, IconClock, IconHome, IconLaptop } from '@posthog/icons'+import { IconClock, IconHome, IconLaptop } from '@posthog/icons'+import { TooltipFooter, TooltipSurface, TooltipSwatch } from '@posthog/quill-charts'import { dayjs } from 'lib/dayjs'import { IconWeb } from 'lib/lemon-ui/icons'@@ -24,18 +25,20 @@ export interface VariantTimeseriesTooltipProps {hasRealData: boolean/** When the timeseries was computed (ISO string), or null if unknown. */computedAt: string | null+ /** The variant line's color, shown as the header swatch. */+ color: string}function TooltipRow({ label, value }: { label: string; value: React.ReactNode }): JSX.Element {return (<div className="flex items-center justify-between gap-4">- <span className="text-secondary">{label}</span>- <span className="font-medium tabular-nums">{value}</span>+ <span className="opacity-60">{label}</span>+ <strong className="tabular-nums">{value}</strong></div>)}-function CalculatedAtRow({+function TimezoneRow({icon,label,caption,@@ -48,17 +51,18 @@ function CalculatedAtRow({}): JSX.Element {return (<div className="flex items-center gap-1.5">- <span className="text-secondary text-base shrink-0">{icon}</span>- <span className="text-secondary">{label}</span>- {caption && <span className="text-secondary text-[0.6875rem]">{caption}</span>}- <span className="ml-auto font-medium tabular-nums">{value}</span>+ <span className="opacity-60 shrink-0">{icon}</span>+ <span className="opacity-60">{label}</span>+ {caption && <span className="opacity-40">{caption}</span>}+ <strong className="ml-auto tabular-nums">{value}</strong></div>)}/**- * Standalone, fully formattable tooltip for the variant timeseries chart.- * Rendered into the shared insight-tooltip DOM via the chart's `external` callback.+ * Tooltip body for the variant timeseries chart, returned from the chart's `tooltip` render prop.+ * Everything below the date is per-point metadata rather than per-series values, so quill's+ * `DefaultTooltip` — one row per series — cannot express it.*/export function VariantTimeseriesTooltip({date,@@ -71,6 +75,7 @@ export function VariantTimeseriesTooltip({significant,hasRealData,computedAt,+ color,}: VariantTimeseriesTooltipProps): JSX.Element {const { currentTeam } = useValues(teamLogic)@@ -79,63 +84,59 @@ export function VariantTimeseriesTooltip({const computedDate = computed?.toDate()return (- <div className="bg-surface-primary border border-primary rounded shadow-md text-[0.8125rem] min-w-[15rem] overflow-hidden">- <div className="px-3 py-2 border-b border-primary font-semibold flex items-center gap-1.5">- <IconCalendar className="text-secondary text-base" />- {dayjs(date).format(DATE_FORMAT)}+ <TooltipSurface>+ <div className="flex items-center gap-2 font-semibold mb-1">+ <TooltipSwatch color={color} />+ <span className="truncate">{dayjs(date).format(DATE_FORMAT)}</span></div>- <div className="px-3 py-2 flex flex-col gap-1">- <TooltipRow label="Delta" value={formatPercent(delta)} />+ <TooltipRow label="Delta" value={formatPercent(delta)} />+ <TooltipRow+ label="Confidence interval"+ value={`${formatPercent(lowerBound)} → ${formatPercent(upperBound)}`}+ />+ {isRatioMetric+ ? denominator !== undefined && <TooltipRow label="Denominator" value={denominator.toLocaleString()} />+ : exposures !== undefined && <TooltipRow label="Exposures" value={exposures.toLocaleString()} />}+ {significant !== undefined && (<TooltipRow- label="Confidence interval"- value={`${formatPercent(lowerBound)} → ${formatPercent(upperBound)}`}+ label="Significant"+ value={+ <span className={significant ? 'text-success' : undefined}>{significant ? 'Yes' : 'No'}</span>+ }/>- {isRatioMetric- ? denominator !== undefined && (- <TooltipRow label="Denominator" value={denominator.toLocaleString()} />- )- : exposures !== undefined && <TooltipRow label="Exposures" value={exposures.toLocaleString()} />}- {significant !== undefined && (- <TooltipRow- label="Significant"- value={- <span className={significant ? 'text-success' : 'text-secondary'}>- {significant ? 'Yes' : 'No'}- </span>- }- />- )}- </div>+ )}{!hasRealData && (- <div className="px-3 py-1.5 border-t border-primary text-warning text-xs flex items-center gap-1.5">- <IconClock className="text-base shrink-0" />- Data pending — showing last known value- </div>+ <TooltipFooter>+ <span className="flex items-center justify-center gap-1.5">+ <IconClock className="shrink-0" />+ Data pending — showing last known value+ </span>+ </TooltipFooter>)}{computed && (- <div className="px-3 py-2 border-t border-primary bg-surface-secondary flex flex-col gap-1 text-xs">- <div className="text-secondary uppercase tracking-wide text-[0.6875rem] font-semibold mb-0.5">+ <div className="mt-1 pt-1 border-t border-current/25 flex flex-col gap-0.5">+ <div className="opacity-50 uppercase tracking-wide font-semibold text-[0.6875rem]">Calculated at</div>{projectTimezone && (- <CalculatedAtRow+ <TimezoneRowicon={<IconHome />}label="Project"caption={shortTimeZone(projectTimezone, computedDate) ?? projectTimezone}value={computed.tz(projectTimezone).format(DATETIME_FORMAT)}/>)}- <CalculatedAtRow+ <TimezoneRowicon={<IconLaptop />}label="Your device"caption={shortTimeZone(undefined, computedDate) ?? ''}value={computed.format(DATETIME_FORMAT)}/>{projectTimezone !== 'UTC' && (- <CalculatedAtRow+ <TimezoneRowicon={<IconWeb />}label="UTC"caption="UTC"@@ -144,6 +145,6 @@ export function VariantTimeseriesTooltip({)}</div>)}- </div>+ </TooltipSurface>)}diff --git a/frontend/src/scenes/experiments/MetricsView/new/variantTimeseriesTransforms.test.ts b/frontend/src/scenes/experiments/MetricsView/new/variantTimeseriesTransforms.test.tsnew file mode 100644index 000000000000..03078c41a4f9--- /dev/null+++ b/frontend/src/scenes/experiments/MetricsView/new/variantTimeseriesTransforms.test.ts@@ -0,0 +1,58 @@+import type { ProcessedTimeseriesDataPoint } from '../../experimentTimeseriesLogic'+import { DELTA_SERIES_KEY, buildVariantTimeseriesSeries } from './variantTimeseriesTransforms'++const VARIANT_COLOR = '#1d4aff'++function points(hasRealData: boolean[]): ProcessedTimeseriesDataPoint[] {+ return hasRealData.map((real, i) => ({+ date: `2026-06-0${i + 1}`,+ value: 0.01 * (i + 1),+ lower_bound: -0.01 * (i + 1),+ upper_bound: 0.02 * (i + 1),+ hasRealData: real,+ }))+}++describe('buildVariantTimeseriesSeries', () => {+ it('dashes from the first pending day, not from the last measured one', () => {+ const { series } = buildVariantTimeseriesSeries(points([true, true, true, false, false]), VARIANT_COLOR)++ expect(series[0].stroke?.partial?.fromIndex).toBe(3)+ })++ it('leaves the line solid when every day is measured', () => {+ const { series } = buildVariantTimeseriesSeries(points([true, true, true]), VARIANT_COLOR)++ expect(series[0].stroke).toBeUndefined()+ })++ it('dashes the whole line when no day has been measured yet', () => {+ const { series } = buildVariantTimeseriesSeries(points([false, false, false]), VARIANT_COLOR)++ expect(series[0].stroke?.partial?.fromIndex).toBe(0)+ })++ it('keeps the series and both confidence bounds the same length as the input', () => {+ const { series, lowerBounds, upperBounds } = buildVariantTimeseriesSeries(+ points([true, true, false]),+ VARIANT_COLOR+ )++ expect(series[0].key).toBe(DELTA_SERIES_KEY)+ expect(series[0].data).toHaveLength(3)+ expect(lowerBounds).toHaveLength(3)+ expect(upperBounds).toHaveLength(3)+ })++ it('substitutes zero for missing values and bounds', () => {+ const missing: ProcessedTimeseriesDataPoint[] = [+ { date: '2026-06-01', value: null, lower_bound: null, upper_bound: null, hasRealData: true },+ ]++ const { series, lowerBounds, upperBounds } = buildVariantTimeseriesSeries(missing, VARIANT_COLOR)++ expect(series[0].data).toEqual([0])+ expect(lowerBounds).toEqual([0])+ expect(upperBounds).toEqual([0])+ })+})diff --git a/frontend/src/scenes/experiments/MetricsView/new/variantTimeseriesTransforms.ts b/frontend/src/scenes/experiments/MetricsView/new/variantTimeseriesTransforms.tsnew file mode 100644index 000000000000..6e90da3e466a--- /dev/null+++ b/frontend/src/scenes/experiments/MetricsView/new/variantTimeseriesTransforms.ts@@ -0,0 +1,44 @@+import type { Series } from '@posthog/quill-charts'++import { findLastIndex } from 'lib/utils/arrays'++import type { ProcessedTimeseriesDataPoint } from '../../experimentTimeseriesLogic'++export const DELTA_SERIES_KEY = 'delta'+const PENDING_DASH_PATTERN = [5, 5]++export interface VariantTimeseriesSeries {+ series: Series[]+ lowerBounds: number[]+ upperBounds: number[]+}++export function buildVariantTimeseriesSeries(+ processedData: ProcessedTimeseriesDataPoint[],+ variantColor: string+): VariantTimeseriesSeries {+ // Days the daily job hasn't computed yet carry the last known value forward, so the line+ // stays continuous — dash the tail to show it isn't measured data. `fromIndex` dashes the+ // segment arriving at that point, so the first dashed segment leaves the last measured day.+ // With no measured day at all `fromIndex` is 0, which dashes the whole line.+ const lastRealIndex = findLastIndex(processedData, (point) => point.hasRealData)+ const firstPendingIndex = lastRealIndex + 1+ const hasPendingTail = firstPendingIndex < processedData.length++ return {+ series: [+ {+ key: DELTA_SERIES_KEY,+ label: 'Delta',+ data: processedData.map((point) => point.value ?? 0),+ color: variantColor,+ points: { radius: 3 },+ stroke: hasPendingTail+ ? { partial: { fromIndex: firstPendingIndex, pattern: PENDING_DASH_PATTERN } }+ : undefined,+ },+ ] satisfies Series[],+ lowerBounds: processedData.map((point) => point.lower_bound ?? 0),+ upperBounds: processedData.map((point) => point.upper_bound ?? 0),+ }+}diff --git a/frontend/src/scenes/experiments/experimentTimeseriesLogic.ts b/frontend/src/scenes/experiments/experimentTimeseriesLogic.tsindex 2bd50f20d842..dc11d7092dbe 100644--- a/frontend/src/scenes/experiments/experimentTimeseriesLogic.ts+++ b/frontend/src/scenes/experiments/experimentTimeseriesLogic.ts@@ -2,10 +2,8 @@ import { MakeLogicType, actions, afterMount, connect, kea, listeners, path, propimport { loaders } from 'kea-loaders'import api from 'lib/api'-import { ChartDataset as ChartJsDataset } from 'lib/Chart'import { getSeriesColor } from 'lib/colors'import { lemonToast } from 'lib/lemon-ui/LemonToast'-import { hexToRGBA } from 'lib/utils/colors'import { eventUsageLogic } from 'lib/utils/eventUsageLogic'import { pluralize } from 'lib/utils/strings'import { teamLogic } from 'scenes/teamLogic'@@ -20,8 +18,7 @@ import {import { Experiment, ExperimentIdType } from '~/types'import type { ExperimentMetricUnion } from '../../queries/schema/schema-general'-import { COLORS } from './MetricsView/shared/colors'-import { getMetricColors, getVariantInterval } from './MetricsView/shared/utils'+import { getVariantInterval } from './MetricsView/shared/utils'import { getExperimentVariants } from './utils'export interface ProcessedTimeseriesDataPoint {@@ -35,23 +32,13 @@ export interface ProcessedTimeseriesDataPoint {significant?: boolean}-export interface ChartDataset extends Partial<ChartJsDataset<'line'>> {- label: string- data: (number | null)[]- borderColor: string- borderWidth: number- borderDash?: number[]- fill: boolean | string- tension: number- pointRadius: number-}-export interface ProcessedChartData {labels: string[]- datasets: ChartDataset[]processedData: ProcessedTimeseriesDataPoint[]/** When the timeseries was last computed (ISO string), shared across all data points. */computedAt: string | null+ /** Color of the variant's line, from the experiment's stable variant order. */+ variantColor: string}export interface ExperimentTimeseriesLogicProps {@@ -157,8 +144,7 @@ export interface experimentTimeseriesLogicMeta {chartData: (processedVariantData: (variantKey: string) => ProcessedTimeseriesDataPoint[],timeseries: ExperimentMetricTimeseries | null,- experiment: Experiment,- metric: ExperimentMetricUnion | undefined+ experiment: Experiment) => (variantKey: string) => ProcessedChartData | null}}@@ -362,17 +348,13 @@ export const experimentTimeseriesLogic = kea<experimentTimeseriesLogicType>([},],- // Generate Chart.js-ready datasetschartData: [- (s, props) => [s.processedVariantData, s.timeseries, props.experiment, props.metric],+ (s, props) => [s.processedVariantData, s.timeseries, props.experiment],(processedVariantData: (variantKey: string) => ProcessedTimeseriesDataPoint[],timeseries: ExperimentMetricTimeseries | null,- experiment: Experiment,- metric: ExperimentMetric | undefined+ experiment: Experiment): ((variantKey: string) => ProcessedChartData | null) => {- // Swap positive/negative colors when the metric goal is "decrease"- const goalColors = getMetricColors(COLORS, metric?.goal)return (variantKey: string) => {const processedData = processedVariantData(variantKey)if (processedData.length === 0) {@@ -396,9 +378,6 @@ export const experimentTimeseriesLogic = kea<experimentTimeseriesLogicType>([firstMeaningfulIndex > 0 ? processedData.slice(firstMeaningfulIndex) : processedDataconst labels = trimmedData.map((d: ProcessedTimeseriesDataPoint) => d.date)- const values = trimmedData.map((d: ProcessedTimeseriesDataPoint) => d.value)- const upperBounds = trimmedData.map((d: ProcessedTimeseriesDataPoint) => d.upper_bound)- const lowerBounds = trimmedData.map((d: ProcessedTimeseriesDataPoint) => d.lower_bound)// Get variant index from the experiment's stable variant order (flag-sourced)let variantIndex = 0@@ -409,110 +388,11 @@ export const experimentTimeseriesLogic = kea<experimentTimeseriesLogicType>([const variantColor = getSeriesColor(variantIndex)- // Create a simple approach: just two datasets with segmented colors- const datasets: ChartDataset[] = []-- // We use the same color for upper and lower bound lines for clear association with the variant line- const boundLineColor = variantColor-- // Upper bounds dataset- datasets.push({- label: 'Upper bound',- data: upperBounds,- borderColor: boundLineColor,- borderWidth: 1,- fill: false,- tension: 0,- pointRadius: 0,- })-- // Lower bounds dataset with significance-based fill- datasets.push({- label: 'Lower bound',- data: lowerBounds,- borderColor: boundLineColor,- borderWidth: 1,- fill: '-1',- backgroundColor: (context: any) => {- if (context.parsed) {- const index = context.dataIndex- const dataPoint = trimmedData[index]- if (dataPoint?.significant) {- const isPositive = dataPoint.value !== null && dataPoint.value > 0- return isPositive- ? hexToRGBA(goalColors.positive, 0.15)- : hexToRGBA(goalColors.negative, 0.15)- }- return hexToRGBA(COLORS.BAR_DEFAULT, 0.1)- }- return hexToRGBA(COLORS.BAR_DEFAULT, 0.1)- },- segment: {- backgroundColor: (ctx: any) => {- const index = ctx.p0DataIndex- const dataPoint = trimmedData[index]- if (dataPoint?.significant) {- const isPositive = dataPoint.value !== null && dataPoint.value > 0- return isPositive- ? hexToRGBA(goalColors.positive, 0.15)- : hexToRGBA(goalColors.negative, 0.15)- }- return hexToRGBA(COLORS.BAR_DEFAULT, 0.1)- },- },- tension: 0,- pointRadius: 0,- })-- // Main variant data (always on top) with segment styling for interpolated data- datasets.push({- label: 'Delta',- data: values,- borderColor: variantColor,- borderWidth: 2,- fill: false,- tension: 0,- pointRadius: 3,- pointBackgroundColor: (context: any) => {- if (context.parsed) {- const index = context.dataIndex- const dataPoint = trimmedData[index]- // Use dimmed color for interpolated data points- return dataPoint?.hasRealData ? variantColor : hexToRGBA(variantColor, 0.5)- }- return variantColor- },- pointBorderColor: (context: any) => {- if (context.parsed) {- const index = context.dataIndex- const dataPoint = trimmedData[index]- // Use dimmed color for interpolated data points- return dataPoint?.hasRealData ? variantColor : hexToRGBA(variantColor, 0.5)- }- return variantColor- },- segment: {- borderColor: (ctx: any) => {- // The segment leads FROM p0 TO p1- // Dim the color if the end point (p1) has no real data- const endIndex = ctx.p1DataIndex- const endDataPoint = trimmedData[endIndex]- return endDataPoint?.hasRealData ? variantColor : hexToRGBA(variantColor, 0.5)- },- borderDash: (ctx: any) => {- // Make it dashed if the end point (p1) has no real data- const endIndex = ctx.p1DataIndex- const endDataPoint = trimmedData[endIndex]- return endDataPoint?.hasRealData ? [] : [5, 5]- },- },- })-return {labels,- datasets,processedData: trimmedData,computedAt: timeseries?.computed_at ?? null,+ variantColor,}}},