: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
fix(quill-charts): render charts when a series has null data (#126983)
posthog[bot]bd7e396fbdd2
diff --git a/packages/quill/packages/charts/src/charts/TimeSeriesLineChart/TimeSeriesLineChart.test.tsx b/packages/quill/packages/charts/src/charts/TimeSeriesLineChart/TimeSeriesLineChart.test.tsxindex 423f3c3da4fd..db03fb6023da 100644--- a/packages/quill/packages/charts/src/charts/TimeSeriesLineChart/TimeSeriesLineChart.test.tsx+++ b/packages/quill/packages/charts/src/charts/TimeSeriesLineChart/TimeSeriesLineChart.test.tsx@@ -498,6 +498,25 @@ describe('TimeSeriesLineChart', () => {)expect(chart.valueLabels()).toHaveLength(3)})++ it('labels the other series instead of failing when one series has null data', () => {+ const onError = jest.fn()+ const series: Series[] = [+ { key: 'a', label: 'A', data: [1, 2, 3] },+ { key: 'formula', label: 'Formula', data: null as unknown as number[] },+ ]+ const { chart } = renderChart(+ <TimeSeriesLineChart+ series={series}+ labels={LABELS}+ theme={THEME}+ config={{ valueLabels: true }}+ onError={onError}+ />+ )+ expect(onError).not.toHaveBeenCalled()+ expect(chart.valueLabels().map((l) => l.text)).toEqual(['1', '2', '3'])+ })})describe('config.goalLines', () => {diff --git a/packages/quill/packages/charts/src/core/chart-shell.tsx b/packages/quill/packages/charts/src/core/chart-shell.tsxindex 6c2f2586d43b..793944abbfc6 100644--- a/packages/quill/packages/charts/src/core/chart-shell.tsx+++ b/packages/quill/packages/charts/src/core/chart-shell.tsx@@ -15,6 +15,9 @@ export function useColoredSeries<Meta = unknown>(series: Series<Meta>[], theme:() =>series.map((s, i) => ({...s,+ // `data` is typed `number[]`, but a query can return `null` (e.g. a trends formula+ // evaluated as a total value). Every renderer and overlay reads `data.length`.+ data: s.data ?? [],color: s.color || theme.colors[i % theme.colors.length],})),[series, theme.colors]