: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): render mixed line+bar SQL insights via quill-charts (#64904)
Sam Penningtond53ad705b924
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 21507b6558d2..86eb2a48354a 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -872,6 +872,22 @@ snapshots:hash: v1.k794b7964.ab7297b86717669855b13de588050fe35027bbcd65350577ad49ab295ef7fde7.thV0LEZMDjM7qJrVZBSc1lRxSt63HSraPkRTuj6Invgcomponents-hogcharts-timeseriesbarchart--y-axis-formats--light:hash: v1.k794b7964.5e57ae6566dc5688ca61fe8c77486391bca3d5e604cd16a52c6a4ceeda09967f.Dq7WVOiz4R9g8BlgBTrQqZ-s-wTr5u8_Qicu2UIQV1o+ components-hogcharts-timeseriescombochart--basic--dark:+ hash: v1.k794b7964.bfc46622a3f7aad15d01c33352f6bbe5f81604f49c6f781d764a50da443fb430.GJfT0GGBUb-IjU5gVl81-NOmzPyfLzi8S7Ii0QbgsQY+ components-hogcharts-timeseriescombochart--basic--light:+ hash: v1.k794b7964.4a9ef4688e15f5d3d106b95b861ea433379e4b67120b2755c07fb33a8c0515bc.Pun2kpeFXrxwosSa_DuVch_nAXXL41c3-XQcbWRjcDA+ components-hogcharts-timeseriescombochart--dual-y-axis--dark:+ hash: v1.k794b7964.d524c1d8169ecf87a6c13279257bde4dc7e1ba8fb6e68ff8deee0b8cef455701.JXNzycaGfUBvXP2YoR_ab0eNhgFpkaA6jcAfxnF7o1s+ components-hogcharts-timeseriescombochart--dual-y-axis--light:+ hash: v1.k794b7964.a6e074e11dfe7b66fd8a8a204e884d2593364ae64e9cef77510d924b763590a1.5ld6CAwccGdKktrerr3euExkM4Yv54SFBZ0eFIC7HeI+ components-hogcharts-timeseriescombochart--stacked-bars-and-line--dark:+ hash: v1.k794b7964.40b382d43e732a29704d74187782193af1aaab0102b767c5df7aed19c1c0dec8.Hmc67OBYl_lC1tNtHwCPHdiwHZFiFoZXuUOqtnBfPpc+ components-hogcharts-timeseriescombochart--stacked-bars-and-line--light:+ hash: v1.k794b7964.1d7f2772f41e3e782617fa20fdc325c31dce20210655bf2838f9a2960227094f.zUfOC23Kle59QG6X3ds5ThdsLYOV2TBdcI8ZaWHBmIQ+ components-hogcharts-timeseriescombochart--with-goal-line--dark:+ hash: v1.k794b7964.65dfcdbb4df857bbb377c60c6cb340b109dd2e40df4f5a70b4f1cad034b3341e.BiHsoQ1fk3BPMN89txx1vCjB6dbn8I0VC8KLVfyAHIs+ components-hogcharts-timeseriescombochart--with-goal-line--light:+ hash: v1.k794b7964.fca72e3fb3a88aa3db97dc25e9af44c3fa689ec28e61b2c97e9757ee1b319a79.39o1MmlThMGqkfgYaV4x-2zRybCKqSOH8wtgOPS9eZEcomponents-hogcharts-timeserieslinechart--basic--dark:hash: v1.k794b7964.c6f75d025b51b76b7554ef0f7d8e4ec930a0245583b676ae4ace4ea23d5d252a.utXBnOCarm7Pt7ZxzP4p4ngKROPHxSbh39WSgVFkSiIcomponents-hogcharts-timeserieslinechart--basic--light:diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/LineGraph.test.ts b/frontend/src/queries/nodes/DataVisualization/Components/Charts/LineGraph.test.tsindex 27bd83da620e..6b1fb732adbd 100644--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/LineGraph.test.ts+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/LineGraph.test.ts@@ -1,5 +1,6 @@import { ChartDisplayType } from '~/types'+import { AxisSeries, AxisSeriesSettings } from '../../dataVisualizationLogic'import { LineGraphProps, sqlChartComponentFor } from './LineGraph'const baseProps = (visualizationType: ChartDisplayType): LineGraphProps => ({@@ -9,6 +10,18 @@ const baseProps = (visualizationType: ChartDisplayType): LineGraphProps => ({chartSettings: {},})+const ySeries = (name: string, settings: AxisSeriesSettings): AxisSeries<number | null> => ({+ column: { name, type: { name: 'INTEGER', isNumerical: true }, label: name, dataIndex: 1 },+ data: [1],+ settings,+})++// A line + bar mix routes neither to the line-only nor the bar-only path.+const mixedYData: AxisSeries<number | null>[] = [+ ySeries('a', { display: { displayType: 'line' } }),+ ySeries('b', { display: { displayType: 'bar' } }),+]+describe('sqlChartComponentFor', () => {it.each([['line', ChartDisplayType.ActionsLineGraph, true, 'SqlLineGraph'],@@ -18,4 +31,19 @@ describe('sqlChartComponentFor', () => {])('routes %s to the right component', (_name, visualizationType, newChartsEnabled, expected) => {expect(sqlChartComponentFor(baseProps(visualizationType), newChartsEnabled).name).toBe(expected)})++ it.each([+ ['a bar-base chart', ChartDisplayType.ActionsBar],+ ['a line-base chart', ChartDisplayType.ActionsLineGraph],+ ])('routes mixed bar + line series on %s to SqlComboGraph', (_name, visualizationType) => {+ expect(sqlChartComponentFor({ ...baseProps(visualizationType), yData: mixedYData }, true).name).toBe(+ 'SqlComboGraph'+ )+ })++ it('keeps mixed series on the legacy path when the flag is off', () => {+ expect(sqlChartComponentFor({ ...baseProps(ChartDisplayType.ActionsBar), yData: mixedYData }, false).name).toBe(+ 'LegacyLineGraph'+ )+ })})diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/LineGraph.tsx b/frontend/src/queries/nodes/DataVisualization/Components/Charts/LineGraph.tsxindex 04cef3747379..14913a4ead42 100644--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/LineGraph.tsx+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/LineGraph.tsx@@ -46,10 +46,12 @@ import { AxisSeries, AxisSeriesSettings, formatDataWithSettings } from '../../daimport { AxisBreakdownSeries } from '../seriesBreakdownLogic'import { lineGraphLogic } from './lineGraphLogic'import { SqlBarGraph } from './SqlBarGraph'+import { SqlComboGraph } from './SqlComboGraph'import { SqlLineGraph } from './SqlLineGraph'import {AREA_FILL_OPACITY,canRenderSqlBarGraph,+ canRenderSqlComboGraph,canRenderSqlLineGraph,capYSeriesData,exceedsMaxSeries,@@ -740,6 +742,9 @@ export function sqlChartComponentFor(if (newChartsEnabled && canRenderSqlBarGraph(props)) {return SqlBarGraph}+ if (newChartsEnabled && canRenderSqlComboGraph(props)) {+ return SqlComboGraph+ }return LegacyLineGraph}diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlComboGraph.tsx b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlComboGraph.tsxnew file mode 100644index 000000000000..3e69e38c26f3--- /dev/null+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlComboGraph.tsx@@ -0,0 +1,41 @@+import clsx from 'clsx'++import { TimeSeriesComboChart } from '@posthog/quill-charts'++import { makeChartErrorHandler } from 'products/product_analytics/frontend/insights/trends/shared/chartErrorHandler'++import { LineGraphProps } from './LineGraph'+import { SqlLineSeriesMeta, buildComboChartConfig } from './sqlLineGraphAdapter'+import { useSqlChartModel } from './useSqlChartModel'++const handleChartError = makeChartErrorHandler('sql-combo-chart')++/**+ * SQL mixed bar + line/area graph rendered via @posthog/quill-charts' {@link TimeSeriesComboChart},+ * gated behind the `product-analytics-quill-sql-charts` flag (see {@link LineGraph}). Handles the+ * mixed-type case the line-only and bar-only paths can't. Tooltip content (per-column formatting,+ * total row) is configured in {@link buildComboChartConfig}.+ */+export const SqlComboGraph = (props: LineGraphProps): JSX.Element => {+ const model = useSqlChartModel(props, buildComboChartConfig)++ return (+ <div+ className={clsx(+ props.className,+ 'rounded bg-surface-primary w-full grow relative overflow-hidden flex flex-col',+ { 'h-[60vh]': props.presetChartHeight, 'h-full': !props.presetChartHeight }+ )}+ >+ {model && (+ <TimeSeriesComboChart<SqlLineSeriesMeta>+ series={model.series}+ labels={model.labels}+ theme={model.theme}+ config={model.config}+ onError={handleChartError}+ />+ )}+ </div>+ )+}diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlLineGraph.tsx b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlLineGraph.tsxindex 3e002e61baa9..3123af38408e 100644--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlLineGraph.tsx+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlLineGraph.tsx@@ -1,12 +1,11 @@import clsx from 'clsx'-import { useCallback } from 'react'-import { DefaultTooltip, TimeSeriesLineChart, type TooltipContext } from '@posthog/quill-charts'+import { TimeSeriesLineChart } from '@posthog/quill-charts'import { makeChartErrorHandler } from 'products/product_analytics/frontend/insights/trends/shared/chartErrorHandler'import { LineGraphProps } from './LineGraph'-import { SqlLineSeriesMeta, buildLineChartConfig, formatSqlSeriesValue } from './sqlLineGraphAdapter'+import { SqlLineSeriesMeta, buildLineChartConfig } from './sqlLineGraphAdapter'import { useSqlChartModel } from './useSqlChartModel'const handleChartError = makeChartErrorHandler('sql-line-chart')@@ -14,27 +13,11 @@ const handleChartError = makeChartErrorHandler('sql-line-chart')/*** SQL line/area graph rendered via @posthog/quill-charts, gated behind the* `product-analytics-quill-sql-charts` flag (see {@link LineGraph}). Handles line, area, goal- * lines, and trend lines; everything else falls back to the legacy chart.js path. The tooltip is quill's- * DefaultTooltip extended to format each row with its column's own settings and to show a total row.+ * lines, and trend lines; everything else falls back to the legacy chart.js path. Tooltip content+ * (per-column formatting, total row) is configured in {@link buildLineChartConfig}.*/export const SqlLineGraph = (props: LineGraphProps): JSX.Element => {const model = useSqlChartModel(props, buildLineChartConfig)- const { chartSettings } = props- const totalSettings = model?.totalFormatterSettings-- const showTotalRow = chartSettings.showTotalRow !== false-- const renderTooltip = useCallback(- (ctx: TooltipContext<SqlLineSeriesMeta>): JSX.Element => (- <DefaultTooltip<SqlLineSeriesMeta>- {...ctx}- valueFormatter={(value, entry) => formatSqlSeriesValue(value, entry.series.meta?.settings)}- showTotal={showTotalRow}- totalFormatter={(value) => formatSqlSeriesValue(value, totalSettings)}- />- ),- [showTotalRow, totalSettings]- )return (<div@@ -50,7 +33,6 @@ export const SqlLineGraph = (props: LineGraphProps): JSX.Element => {labels={model.labels}theme={model.theme}config={model.config}- tooltip={renderTooltip}onError={handleChartError}/>)}diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlLineGraphAdapter.test.ts b/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlLineGraphAdapter.test.tsindex 324bed679000..4974018e6b3f 100644--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlLineGraphAdapter.test.ts+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlLineGraphAdapter.test.ts@@ -1,4 +1,4 @@-import { type TrendLineConfig } from '@posthog/quill-charts'+import { type TooltipContext, type TrendLineConfig } from '@posthog/quill-charts'import { ChartSettings, GoalLine } from '~/queries/schema/schema-general'import { ChartDisplayType } from '~/types'@@ -12,14 +12,20 @@ import {type SqlLineYSeries,barLayoutForDisplay,buildBarChartConfig,+ buildComboChartConfig,buildLineChartConfig,buildSeries,+ buildSqlTooltipConfig,buildTrendLineConfigs,canRenderSqlBarGraph,+ canRenderSqlComboGraph,canRenderSqlLineGraph,capYSeriesData,+ comboBarLayoutForDisplay,exceedsMaxSeries,formatSqlSeriesValue,+ hasMixedSeriesTypes,+ seriesDisplayType,} from './sqlLineGraphAdapter'const numericColumn = (name: string, dataIndex: number): AxisSeries<number | null>['column'] => ({@@ -118,6 +124,136 @@ describe('sqlLineGraphAdapter', () => {})})+ describe('seriesDisplayType', () => {+ it.each<[string, ChartDisplayType, AxisSeries<number | null>['settings'], string]>([+ ['bar override wins', ChartDisplayType.ActionsLineGraph, { display: { displayType: 'bar' } }, 'bar'],+ ['line override wins', ChartDisplayType.ActionsBar, { display: { displayType: 'line' } }, 'line'],+ ['area override wins', ChartDisplayType.ActionsBar, { display: { displayType: 'area' } }, 'area'],+ ['auto on a line graph is a line', ChartDisplayType.ActionsLineGraph, {}, 'line'],+ ['auto on an area graph is an area', ChartDisplayType.ActionsAreaGraph, {}, 'area'],+ ['auto on a bar graph is a bar', ChartDisplayType.ActionsBar, {}, 'bar'],+ ['auto on a stacked bar graph is a bar', ChartDisplayType.ActionsStackedBar, {}, 'bar'],+ [+ "the 'auto' display type defers to the chart type",+ ChartDisplayType.ActionsBar,+ { display: { displayType: 'auto' } },+ 'bar',+ ],+ ])('derives %s', (_name, visualizationType, settings, expected) => {+ expect(seriesDisplayType(visualizationType, settings)).toBe(expected)+ })+ })++ describe('hasMixedSeriesTypes', () => {+ it.each<[string, ChartDisplayType, AxisSeries<number | null>[], boolean]>([+ [+ 'bar + line on a line graph',+ ChartDisplayType.ActionsLineGraph,+ [ySeries('a', [1]), ySeries('b', [2], { display: { displayType: 'bar' } })],+ true,+ ],+ [+ 'line + bar on a bar graph',+ ChartDisplayType.ActionsBar,+ [ySeries('a', [1]), ySeries('b', [2], { display: { displayType: 'line' } })],+ true,+ ],+ [+ 'bar + area on a stacked bar graph',+ ChartDisplayType.ActionsStackedBar,+ [ySeries('a', [1]), ySeries('b', [2], { display: { displayType: 'area' } })],+ true,+ ],+ [+ 'all lines on a line graph',+ ChartDisplayType.ActionsLineGraph,+ [ySeries('a', [1]), ySeries('b', [2])],+ false,+ ],+ ['all bars on a bar graph', ChartDisplayType.ActionsBar, [ySeries('a', [1]), ySeries('b', [2])], false],+ [+ 'line + area is line-like, not mixed',+ ChartDisplayType.ActionsLineGraph,+ [ySeries('a', [1]), ySeries('b', [2], { display: { displayType: 'area' } })],+ false,+ ],+ ])('detects %s', (_name, visualizationType, yData, expected) => {+ expect(hasMixedSeriesTypes(yData, visualizationType)).toBe(expected)+ })+ })++ describe('canRenderSqlComboGraph', () => {+ // Explicit line + bar so the mix holds regardless of the base chart type's auto resolution.+ const mixed = [+ ySeries('a', [1], { display: { displayType: 'line' } }),+ ySeries('b', [2], { display: { displayType: 'bar' } }),+ ]++ it.each([+ ['line graph', ChartDisplayType.ActionsLineGraph],+ ['area graph', ChartDisplayType.ActionsAreaGraph],+ ['bar graph', ChartDisplayType.ActionsBar],+ ['stacked bar graph', ChartDisplayType.ActionsStackedBar],+ ])('renders mixed series on a %s', (_name, visualizationType) => {+ expect(canRenderSqlComboGraph(baseProps({ visualizationType, yData: mixed }))).toBe(true)+ })++ it('does not render when series are all one type', () => {+ const yData = [ySeries('a', [1]), ySeries('b', [2])]+ expect(canRenderSqlComboGraph(baseProps({ visualizationType: ChartDisplayType.ActionsBar, yData }))).toBe(+ false+ )+ })++ it('does not claim an unsupported chart type', () => {+ expect(+ canRenderSqlComboGraph(baseProps({ visualizationType: ChartDisplayType.ActionsPie, yData: mixed }))+ ).toBe(false)+ })++ it('falls back when any series has a trend line (no combo trend-line support)', () => {+ const yData = [+ ySeries('a', [1], { display: { displayType: 'bar' } }),+ ySeries('b', [2], { display: { displayType: 'line', trendLine: true } }),+ ]+ expect(canRenderSqlComboGraph(baseProps({ visualizationType: ChartDisplayType.ActionsBar, yData }))).toBe(+ false+ )+ })++ it('falls back for percent-stacked bars (unsupported by ComboChart)', () => {+ expect(+ canRenderSqlComboGraph(+ baseProps({+ visualizationType: ChartDisplayType.ActionsStackedBar,+ yData: mixed,+ chartSettings: { stackBars100: true },+ })+ )+ ).toBe(false)+ })++ it('falls back when any series targets the right y-axis', () => {+ const yData = [+ ySeries('a', [1], { display: { displayType: 'bar' } }),+ ySeries('b', [2], { display: { displayType: 'line', yAxisPosition: 'right' } }),+ ]+ expect(canRenderSqlComboGraph(baseProps({ visualizationType: ChartDisplayType.ActionsBar, yData }))).toBe(+ false+ )+ })+ })++ describe('comboBarLayoutForDisplay', () => {+ it.each([+ ['stacked for a stacked bar graph', ChartDisplayType.ActionsStackedBar, 'stacked'],+ ['grouped for a bar graph', ChartDisplayType.ActionsBar, 'grouped'],+ ['grouped for a line graph', ChartDisplayType.ActionsLineGraph, 'grouped'],+ ])('returns %s', (_name, visualizationType, expected) => {+ expect(comboBarLayoutForDisplay(visualizationType)).toBe(expected)+ })+ })+describe('barLayoutForDisplay', () => {it.each([['grouped bars for a bar graph', ChartDisplayType.ActionsBar, {}, 'grouped'],@@ -198,11 +334,32 @@ describe('sqlLineGraphAdapter', () => {expect(series.fill).toBeUndefined()})+ it('omits the area fill for a bar-override series on an area graph', () => {+ const [series] = buildSeries(+ [ySeries('a', [1], { display: { displayType: 'bar' } })],+ ChartDisplayType.ActionsAreaGraph+ )+ expect(series.type).toBe('bar')+ expect(series.fill).toBeUndefined()+ })+it('keys breakdown series by breakdown value', () => {const [series] = buildSeries([breakdownSeries('chrome', [1])], ChartDisplayType.ActionsLineGraph)expect(series.key).toBe('chrome')})+ it('derives each series quill type from its displayType', () => {+ const [bar, line, area] = buildSeries(+ [+ ySeries('a', [1], { display: { displayType: 'bar' } }),+ ySeries('b', [2]),+ ySeries('c', [3], { display: { displayType: 'area' } }),+ ],+ ChartDisplayType.ActionsLineGraph+ )+ expect([bar.type, line.type, area.type]).toEqual(['bar', 'line', 'area'])+ })+it('threads each series settings through meta for the tooltip', () => {const usd: AxisSeries<number | null>['settings'] = { formatting: { prefix: '$' } }const [withSettings, plain] = buildSeries(@@ -276,6 +433,40 @@ describe('sqlLineGraphAdapter', () => {})})+ describe('buildSqlTooltipConfig', () => {+ const entry = (settings: AxisSeries<number | null>['settings']): TooltipContext['seriesData'][number] => ({+ series: { key: 'r', label: 'Revenue', data: [1200], meta: { settings } },+ value: 1200,+ color: '#000000',+ })++ it('enables a pinnable tooltip', () => {+ const config = buildSqlTooltipConfig({}, [ySeries('a', [1])])+ expect(config.enabled).toBe(true)+ expect(config.pinnable).toBe(true)+ })++ it('formats each row with its own column settings from series.meta', () => {+ const config = buildSqlTooltipConfig({}, [ySeries('a', [1])])+ const format = config.valueFormatter!+ expect(format(1200, entry({ formatting: { prefix: '$' } }))).toBe('$1200')+ })++ it.each([+ ['shows the total row by default', {}, true],+ ['shows the total row when showTotalRow is true', { showTotalRow: true }, true],+ ['hides the total row when showTotalRow is false', { showTotalRow: false }, false],+ ])('%s', (_name, chartSettings, expected) => {+ expect(buildSqlTooltipConfig(chartSettings as ChartSettings, []).showTotal).toBe(expected)+ })++ it('formats the total with the first series settings', () => {+ const config = buildSqlTooltipConfig({}, [ySeries('revenue', [1], { formatting: { prefix: '$' } })])+ const formatTotal = config.totalFormatter!+ expect(formatTotal(5000)).toBe('$5000')+ })+ })+describe('buildLineChartConfig', () => {const dateXData: AxisSeries<string> = {column: { name: 'day', type: { name: 'DATE', isNumerical: false }, label: 'day', dataIndex: 0 },@@ -370,4 +561,49 @@ describe('sqlLineGraphAdapter', () => {expect('trendLines' in config).toBe(false)})})++ describe('buildComboChartConfig', () => {+ const dateXData: AxisSeries<string> = {+ column: { name: 'day', type: { name: 'DATE', isNumerical: false }, label: 'day', dataIndex: 0 },+ data: ['2024-01-01', '2024-01-02'],+ }++ it.each([+ ['grouped bars for a bar graph', ChartDisplayType.ActionsBar, 'grouped'],+ ['stacked bars for a stacked bar graph', ChartDisplayType.ActionsStackedBar, 'stacked'],+ ['grouped bars for a line graph', ChartDisplayType.ActionsLineGraph, 'grouped'],+ ])('uses %s', (_name, visualizationType, expected) => {+ const config = buildComboChartConfig({+ xData: dateXData,+ chartSettings: {},+ timezone: 'UTC',+ visualizationType,+ })+ expect(config.barLayout).toBe(expected)+ })++ it('wires goal lines, legend, and a date x-axis formatter', () => {+ const config = buildComboChartConfig({+ xData: dateXData,+ chartSettings: { showLegend: true },+ timezone: 'UTC',+ visualizationType: ChartDisplayType.ActionsBar,+ goalLines: [{ label: 'Target', value: 100 }],+ })+ expect(config.xAxis?.tickFormatter).toBeInstanceOf(Function)+ expect(config.goalLines).toHaveLength(1)+ expect(config.legend).toEqual({ show: true, position: 'top', interactive: true })+ expect(config.tooltip).toMatchObject({ enabled: true, pinnable: true })+ })++ it('never emits trend lines (combo charts have no trend-line support)', () => {+ const config = buildComboChartConfig({+ xData: dateXData,+ chartSettings: {},+ timezone: 'UTC',+ visualizationType: ChartDisplayType.ActionsBar,+ })+ expect('trendLines' in config).toBe(false)+ })+ })})diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlLineGraphAdapter.ts b/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlLineGraphAdapter.tsindex 7e9c04ed4a38..7d13657216a5 100644--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlLineGraphAdapter.ts+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlLineGraphAdapter.ts@@ -2,8 +2,12 @@ import { lemonToast } from '@posthog/lemon-ui'import {type ChartLegendConfig,type Series,+ type SeriesType,type TimeSeriesBarChartConfig,+ type TimeSeriesComboChartConfig,type TimeSeriesLineChartConfig,+ type TooltipConfig,+ type TooltipContext,type TrendLineConfig,type XAxisConfig,type YAxisConfig,@@ -29,6 +33,51 @@ export type SqlLineYSeries = AxisSeries<number | null> | AxisBreakdownSeries<numexport const isAreaSeries = (visualizationType: ChartDisplayType, settings: AxisSeriesSettings | undefined): boolean =>visualizationType === ChartDisplayType.ActionsAreaGraph || settings?.display?.displayType === 'area'+/** Per-series quill `type` that drives mixed-type rendering on {@link ComboChart}. */+export function seriesDisplayType(+ visualizationType: ChartDisplayType,+ settings: AxisSeriesSettings | undefined+): SeriesType {+ const displayType = settings?.display?.displayType+ if (displayType === 'bar') {+ return 'bar'+ }+ if (displayType === 'line') {+ return 'line'+ }+ if (displayType === 'area') {+ return 'area'+ }+ if (visualizationType === ChartDisplayType.ActionsBar || visualizationType === ChartDisplayType.ActionsStackedBar) {+ return 'bar'+ }+ if (visualizationType === ChartDisplayType.ActionsAreaGraph) {+ return 'area'+ }+ return 'line'+}++/** True when the series resolve to a mix of bar and line/area — the case neither the line-only nor+ * the bar-only quill path can render, so it routes to {@link SqlComboGraph}. */+export function hasMixedSeriesTypes(+ yData: NonNullable<LineGraphProps['yData']>,+ visualizationType: ChartDisplayType+): boolean {+ let hasBar = false+ let hasLineLike = false+ for (const series of yData) {+ if (seriesDisplayType(visualizationType, series.settings) === 'bar') {+ hasBar = true+ } else {+ hasLineLike = true+ }+ if (hasBar && hasLineLike) {+ return true+ }+ }+ return false+}+const getSeriesLabel = (series: SqlLineYSeries): string => ('name' in series ? series.name : series.column.name)const getSeriesKey = (series: SqlLineYSeries, index: number): string =>@@ -48,8 +97,9 @@ export function buildTrendLineConfigs(ySeriesData: SqlLineYSeries[] | null | und}/**- * Plain line/area charts — including goal lines and trend lines — render here. Mixed line/bar series- * and right y-axis series aren't ported yet, so those fall back to the legacy chart.js path.+ * Plain line/area charts — including goal lines and trend lines — render here. Series that mix a bar+ * with a line/area route to {@link canRenderSqlComboGraph}; right y-axis series aren't ported yet, so+ * those fall back to the legacy chart.js path.*/export function canRenderSqlLineGraph(props: LineGraphProps): boolean {const { visualizationType, yData } = props@@ -95,6 +145,39 @@ export function canRenderSqlBarGraph(props: LineGraphProps): boolean {return true}+/**+ * Mixed bar + line/area series render on quill's {@link TimeSeriesComboChart}. Trend lines and+ * percent-stacked layouts (unsupported by ComboChart) and right y-axis series (a single tick+ * formatter can't honor a second gutter's settings yet) still fall back to legacy chart.js.+ */+export function canRenderSqlComboGraph(props: LineGraphProps): boolean {+ const { visualizationType, yData, chartSettings } = props++ if (+ visualizationType !== ChartDisplayType.ActionsLineGraph &&+ visualizationType !== ChartDisplayType.ActionsAreaGraph &&+ visualizationType !== ChartDisplayType.ActionsBar &&+ visualizationType !== ChartDisplayType.ActionsStackedBar+ ) {+ return false+ }+ if (!yData || !hasMixedSeriesTypes(yData, visualizationType)) {+ return false+ }+ // ComboChart has no trend-line support yet (same limitation as the bar path).+ if (yData.some((series) => series.settings?.display?.trendLine)) {+ return false+ }+ // ComboChart supports only stacked/grouped bars, not percent (stackBars100).+ if (barLayoutForDisplay(visualizationType, chartSettings) === 'percent') {+ return false+ }+ if (yData.some((series) => series.settings?.display?.yAxisPosition === 'right')) {+ return false+ }+ return true+}+export function barLayoutForDisplay(visualizationType: ChartDisplayType,chartSettings: ChartSettings@@ -105,6 +188,14 @@ export function barLayoutForDisplay(return 'grouped'}+/** Bar layout for the combo path — stacked for stacked-bar charts, grouped otherwise. ComboChart+ * doesn't support percent, so {@link canRenderSqlComboGraph} keeps stackBars100 on the legacy path. */+export function comboBarLayoutForDisplay(+ visualizationType: ChartDisplayType+): NonNullable<TimeSeriesComboChartConfig['barLayout']> {+ return visualizationType === ChartDisplayType.ActionsStackedBar ? 'stacked' : 'grouped'+}+/** Returns true when {@link MAX_SERIES} is exceeded and the user should be warned (not on dashboards). */export function exceedsMaxSeries(yData: LineGraphProps['yData'], dashboardId: LineGraphProps['dashboardId']): boolean {return !!yData && yData.length > MAX_SERIES && !dashboardId@@ -134,6 +225,7 @@ export function buildSeries(yData: SqlLineYSeries[], visualizationType: ChartDisreturn yData.map((series, index) => {const settings = series.settingsconst color = settings?.display?.color+ const type = seriesDisplayType(visualizationType, settings)return {key: getSeriesKey(series, index),@@ -141,9 +233,15 @@ export function buildSeries(yData: SqlLineYSeries[], visualizationType: ChartDis// null -> NaN so quill draws a gap rather than a zero.data: series.data.map((value) => (value == null ? NaN : value)),meta: { settings },+ // Per-series type; ignored by the single-type line/bar charts, read by ComboChart.+ type,// Only pin an explicit color; otherwise let quill assign palette colors by index....(color ? { color } : {}),- ...(isAreaSeries(visualizationType, settings) ? { fill: { opacity: AREA_FILL_OPACITY } } : {}),+ // Area fill, but never on a bar — a bar-override on an area-graph chart resolves to+ // `type: 'bar'` yet `isAreaSeries` is still true for the whole area graph.+ ...(type !== 'bar' && isAreaSeries(visualizationType, settings)+ ? { fill: { opacity: AREA_FILL_OPACITY } }+ : {}),}})}@@ -153,6 +251,23 @@ export function formatSqlSeriesValue(value: number, settings?: AxisSeriesSettingreturn String(formatDataWithSettings(value, settings) ?? value)}+/** Built-in tooltip for the line + combo SQL charts: each row formatted by its column's settings+ * (from `series.meta`), plus an optional total row. */+export function buildSqlTooltipConfig(+ chartSettings: ChartSettings,+ ySeriesData?: SqlLineYSeries[] | null+): TooltipConfig {+ const totalSettings = ySeriesData?.[0]?.settings+ return {+ enabled: true,+ pinnable: true,+ valueFormatter: (value: number, entry: TooltipContext['seriesData'][number]) =>+ formatSqlSeriesValue(value, (entry.series.meta as SqlLineSeriesMeta | undefined)?.settings),+ showTotal: chartSettings.showTotalRow !== false,+ totalFormatter: (value: number) => formatSqlSeriesValue(value, totalSettings),+ }+}+interface BuildConfigArgs {xData: AxisSeries<string>chartSettings: ChartSettings@@ -206,7 +321,7 @@ export function buildLineChartConfig({goalLines: schemaGoalLinesToConfigs(goalLines),trendLines: buildTrendLineConfigs(ySeriesData),legend: buildLegendConfig(chartSettings),- tooltip: { enabled: true, pinnable: true },+ tooltip: buildSqlTooltipConfig(chartSettings, ySeriesData),}}@@ -228,3 +343,21 @@ export function buildBarChartConfig({tooltip: { enabled: true, pinnable: true },}}++export function buildComboChartConfig({+ xData,+ chartSettings,+ timezone,+ goalLines,+ visualizationType,+ ySeriesData,+}: BuildBarConfigArgs): TimeSeriesComboChartConfig {+ return {+ xAxis: buildXAxisConfig(xData, chartSettings, timezone),+ yAxis: buildYAxisConfig(chartSettings),+ goalLines: schemaGoalLinesToConfigs(goalLines),+ barLayout: comboBarLayoutForDisplay(visualizationType),+ legend: buildLegendConfig(chartSettings),+ tooltip: buildSqlTooltipConfig(chartSettings, ySeriesData),+ }+}diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/useSqlChartModel.ts b/frontend/src/queries/nodes/DataVisualization/Components/Charts/useSqlChartModel.tsindex 88d3f6e69984..2c927f4f103c 100644--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/useSqlChartModel.ts+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/useSqlChartModel.ts@@ -8,7 +8,6 @@ import { teamLogic } from 'scenes/teamLogic'import { themeLogic } from '~/layout/navigation-3000/themeLogic'-import { AxisSeriesSettings } from '../../dataVisualizationLogic'import { LineGraphProps } from './LineGraph'import {type BuildBarConfigArgs,@@ -24,7 +23,6 @@ export interface SqlChartModel<TConfig> {labels: string[]theme: ChartThemeconfig: TConfig- totalFormatterSettings?: AxisSeriesSettings}export function useSqlChartModel<TConfig>(@@ -69,5 +67,5 @@ export function useSqlChartModel<TConfig>(return null}- return { series, labels: xData.data, theme, config, totalFormatterSettings: ySeriesData[0]?.settings }+ return { series, labels: xData.data, theme, config }}diff --git a/packages/quill/packages/charts/AGENTS.md b/packages/quill/packages/charts/AGENTS.mdindex 0d77289d8ee3..65c6b3065570 100644--- a/packages/quill/packages/charts/AGENTS.md+++ b/packages/quill/packages/charts/AGENTS.md@@ -4,18 +4,19 @@ Quick-reference for AI agents using `@posthog/quill-charts`. Canvas-rendered cha## Choosing a chart-| Chart | Use when |-| ------------------- | ------------------------------------------------------------------------------------------------------------------------------- |-| LineChart | Categorical x-axis trends; area fills, fill-between (confidence ribbons) |-| BarChart | Categorical comparisons — `barLayout: 'stacked' \| 'grouped' \| 'percent'`, `axisOrientation: 'horizontal'` for horizontal bars |-| ComboChart | Mixed bar/line/area series on one band x-axis — set `Series.type`; vertical-only, `barLayout: 'stacked' \| 'grouped'` |-| TimeSeriesLineChart | Time-indexed labels (ISO strings) with timezone/interval-aware x-axis |-| TimeSeriesBarChart | Same x-axis handling, bar rendering; supports per-series `yAxisId` axes |-| PieChart | Part-of-whole, one value per series; `innerRadiusRatio` for donut + `centerLabel` |-| BoxPlot | Distribution summaries — `{ min, p25, median, mean, p75, max }` per label |-| Sparkline | Tiny inline trend from a flat `number[]` — no axes, no series structure |-| MetricCard | Headline number + sparkline + change pill (dashboard stat tiles) |-| SlopeChart | Change between two points (slopegraph) — one line per series, left "before" → right "after"; `data: [start, end]` |+| Chart | Use when |+| -------------------- | --------------------------------------------------------------------------------------------------------------------------------- |+| LineChart | Categorical x-axis trends; area fills, fill-between (confidence ribbons) |+| BarChart | Categorical comparisons — `barLayout: 'stacked' \| 'grouped' \| 'percent'`, `axisOrientation: 'horizontal'` for horizontal bars |+| ComboChart | Mixed bar/line/area series on one band x-axis — set `Series.type`; vertical-only, `barLayout: 'stacked' \| 'grouped'` |+| TimeSeriesLineChart | Time-indexed labels (ISO strings) with timezone/interval-aware x-axis |+| TimeSeriesBarChart | Same x-axis handling, bar rendering; supports per-series `yAxisId` axes |+| TimeSeriesComboChart | Mixed bar + line/area on a time x-axis — `ComboChart` plus the time-series chrome (date x-axis, goal lines, legend, value labels) |+| PieChart | Part-of-whole, one value per series; `innerRadiusRatio` for donut + `centerLabel` |+| BoxPlot | Distribution summaries — `{ min, p25, median, mean, p75, max }` per label |+| Sparkline | Tiny inline trend from a flat `number[]` — no axes, no series structure |+| MetricCard | Headline number + sparkline + change pill (dashboard stat tiles) |+| SlopeChart | Change between two points (slopegraph) — one line per series, left "before" → right "after"; `data: [start, end]` |## Theme wiring@@ -67,12 +68,14 @@ Charts fill their container and need a parent with real dimensions — a `0`-hei- Overlays (`ReferenceLine`/`ReferenceLines`, `ValueLabels`, `AxisTitles`) compose as children.- `DefaultTooltip` (the built-in tooltip, also usable from a custom `tooltip` render prop) takes optional `valueFormatter`, `showTotal`, `totalLabel`, `totalFormatter`. `valueFormatter` gets `(value, entry)` — the row's `seriesData` entry as a second arg — so each row can format with its own `series.meta` (e.g. per-column currency/duration). `showTotal` appends a footer row summing the visible series; it excludes `overlay` series (goal lines) from the sum and is suppressed when fewer than two summable series remain. `totalFormatter` formats the total (defaults to `valueFormatter` applied with the first summable row's entry); `totalLabel` defaults to `'Total'`. A formatter taking only `value` stays compatible — the extra arg is ignored.+- To tune the built-in tooltip **without writing a render prop**, put those same four fields on `config.tooltip` (`{ enabled, pinnable, placement, valueFormatter, showTotal, totalLabel, totalFormatter }`). When no `tooltip` render prop is supplied, the chart renders `DefaultTooltip` with them applied; a render prop, if given, owns content entirely and these are ignored. Prefer config for "format each row / add a total" cases (e.g. SQL insights pass per-column formatters this way) and reach for the render prop only for genuinely custom tooltip markup.- `ReferenceLine` variants: `goal` (dashed grey), `alert` (dashed red), `marker` (solid thin).- `ValueLabels` formatter gets `(value, seriesIndex, dataIndex, context)`; in percent layouts `value` is a 0–1 fraction — use `context.rawValue` for the original.- Every multi-series chart (`LineChart`, `BarChart`, `TimeSeriesLineChart`, `TimeSeriesBarChart`, `SlopeChart`) takes a `config.legend: ChartLegendConfig` (`{ show, position, align, gap, interactive, hiddenKeys, onToggleSeries, renderItem }`). With `show: true` the chart renders a built-in legend that, by default (`interactive`), is click-to-toggle: clicking a row hides that series (no draw, no scale contribution, no tooltip — the axes rescale into the freed space) while the row stays listed but dimmed so it can be restored. The chart owns the toggled-off state (uncontrolled); set `interactive: false` for a static legend, or pass `hiddenKeys` + `onToggleSeries` to control it yourself. Hidden by default. `config.legend.renderItem(defaultNode, item)` wraps each rendered row, so consumers can augment it (e.g. attach a right-click context menu) while keeping the default swatch/label/toggle rendering — return `defaultNode` to leave a row untouched. Toggling on time-series charts lists the user's series only (not derived trend lines / CI bands) — and hiding a series also hides everything derived from it (its CI band, moving average, and trend line), so no orphaned overlay floats over the gap.- `Legend` (and `ChartLegend` for layout) is the lower-level presentational primitive: pass `items`, `onItemClick`, `hiddenKeys` — filtering series is the caller's state. Use it directly when the built-in `config.legend` can't express what you need (custom item order/labels). `useChartLegend(series, theme, config, items?)` is the shared hook the charts use — returns `visibleSeries` (hidden applied as `visibility.excluded`) plus `legendProps` to spread onto `<ChartLegend>`; `applyHiddenSeries` is the underlying helper. `LegendItem.secondaryLabel` shows muted trailing text (e.g. a slope chart's per-series change).- `SlopeChart` config: `showSeriesLabels` (name beside each point; steepest line wins label collisions), `showStartLabels`/`showEndLabels` (defaults overridable per series via `meta.showStartLabel`/`showEndLabel`), `legend` (`{ show, position }`, rows carry the formatted change, ordered biggest-to-smallest by end value to match the lines' right-edge order), `valueFormatter`/`deltaFormatter`. The value axis is hidden by default — the start/end labels are the readout. The default tooltip orders its rows biggest-to-smallest by the hovered point's value (so many-breakdown tooltips match the lines' vertical order) and formats values with `valueFormatter` so they match the on-chart labels' units; pass your own `tooltip` to override. (`DefaultTooltip` itself takes an optional `valueFormatter` for the same reason — without it values fall back to `toLocaleString`.) Per-series `meta.incompleteEnd` dashes only the second half of that connector (the last point is the current incomplete period); the renderer splits the final segment at its midpoint via `stroke.partial.fromFraction`, so a two-point line needs no phantom interior point.- `MetricCard` is a left-aligned tile. Pass `title={null}` to drop the title row — the header band collapses when there is no title and no change pill, and the subtitle row is omitted when there is no subtitle (and no `labels`), so a value-only card renders just the number. `changeSize="md"` renders a larger change pill (default `sm`); `changeInline` puts the pill beside the headline instead of in the header; `sparklineFill` makes the sparkline fill the card's remaining height instead of a fixed `sparklineHeight`. `subtitle` always wins (shown at rest and on hover); `restingSubtitle` (e.g. `'Avg'`) shows only at rest and yields to the hovered point's label on hover — pair it with a `value` that summarizes the series (average/total) so the headline reads as a summary until hovered. `hoverChangeFromPreviousPoint` keeps the supplied resting `change` pill at rest but, while hovering, swaps it for the hovered point's change vs the previous point (hidden at the first point).+- `TimeSeriesComboChart` wraps `ComboChart` the way `TimeSeriesLineChart`/`TimeSeriesBarChart` wrap their base charts: `config.xAxis`/`config.yAxis` (date tick formatter, y-format, scale, grid), `config.goalLines` (off-scale targets stretch the value axis via `ComboChart`'s `valueDomain`), `config.legend` (click-to-toggle), and `config.valueLabels`. Per-series `type` (`'bar' | 'line' | 'area'`) drives rendering; `barLayout` (`'stacked' | 'grouped'`) and right-axis series (`yAxisId: 'right'`) carry over from `ComboChart`. `ComboChart` itself now also honors `valueDomain` (primary axis only) and `showAxisLines`.- y-axis `format`: `numeric | short | percentage | percentage_scaled | currency | duration | duration-ms`, plus `prefix`/`suffix`.- Dual / multi y-axis: give a series a `yAxisId` to scale it against a second axis. On `TimeSeriesLineChart`, pass `config.yAxis` as an **array** — one `YAxisConfig` per axis — to format/scale each axis independently: set `id` (matches `Series.yAxisId`; first entry defaults to `'left'`), `position` (`'left'`/`'right'`; first entry defaults to `'left'`, the rest to `'right'`), and the usual `scale`/`format`/`tickFormatter`/`label`/`showGrid` per entry. A single object stays single-axis (unchanged). The second axis only renders when a series actually targets it; the primary (left) axis owns the gridlines. `TimeSeriesBarChart`/`ComboChart` already render per-`yAxisId` axes but share one tick formatter across gutters.- `onDateRangeZoom` (on `LineChart`/`TimeSeriesLineChart`/base `Chart`) enables x-axis drag-to-zoom: the user drags horizontally and the callback fires once with `{ startLabel, endLabel, startIndex, endIndex }` for the spanned range. The cursor switches to a crosshair when set. x-axis only — no effect on charts with a vertical interaction axis.diff --git a/packages/quill/packages/charts/src/charts/ComboChart/ComboChart.tsx b/packages/quill/packages/charts/src/charts/ComboChart/ComboChart.tsxindex f89f8d4e9cd4..5b84b3f2756f 100644--- a/packages/quill/packages/charts/src/charts/ComboChart/ComboChart.tsx+++ b/packages/quill/packages/charts/src/charts/ComboChart/ComboChart.tsx@@ -5,6 +5,7 @@ import { bandCenter, buildBarLayers, computeBarAtIndex, groupedBarCenter } fromimport {BAR_HIGHLIGHT_DARKEN,DEFAULT_BAR_CORNER_RADIUS,+ drawAxes,drawBarHighlight,drawBars,drawGrid,@@ -80,10 +81,12 @@ function ComboChartInner<Meta = unknown>({const {yScaleType = 'linear',showGrid = false,+ showAxisLines = false,barLayout = 'stacked',barCornerRadius = DEFAULT_BAR_CORNER_RADIUS,defaultSeriesType = DEFAULT_SERIES_TYPE,xTickFormatter,+ valueDomain,} = config ?? {}const seriesTypeOf = useCallback(@@ -121,6 +124,7 @@ function ComboChartInner<Meta = unknown>({barLayout,seriesTypeOf,barStackedData,+ valueDomain,})const yTickCount = yTickCountForHeight(dimensions.plotHeight)@@ -153,7 +157,7 @@ function ComboChartInner<Meta = unknown>({_private: comboPrivate,}},- [yScaleType, barLayout, seriesTypeOf, barStackedData]+ [yScaleType, barLayout, seriesTypeOf, barStackedData, valueDomain])const drawStatic = useCallback(@@ -180,6 +184,8 @@ function ComboChartInner<Meta = unknown>({xTickFormatter).map((entry) => entry.x)drawGrid(baseDrawCtx, { gridColor: theme.gridColor, categoryTicks })+ } else if (showAxisLines) {+ drawAxes(baseDrawCtx, { axisColor: theme.gridColor })}// ── 1. Bars ──────────────────────────────────────────────────────────────────────@@ -213,7 +219,16 @@ function ComboChartInner<Meta = unknown>({zOrder: 'areas-first',})},- [seriesTypeOf, showGrid, xTickFormatter, barLayout, barStackedData, topStackedKeyByAxis, barCornerRadius]+ [+ seriesTypeOf,+ showGrid,+ showAxisLines,+ xTickFormatter,+ barLayout,+ barStackedData,+ topStackedKeyByAxis,+ barCornerRadius,+ ])const drawHover = useCallback(diff --git a/packages/quill/packages/charts/src/charts/TimeSeriesComboChart/TimeSeriesComboChart.stories.tsx b/packages/quill/packages/charts/src/charts/TimeSeriesComboChart/TimeSeriesComboChart.stories.tsxnew file mode 100644index 000000000000..ce202af252a0--- /dev/null+++ b/packages/quill/packages/charts/src/charts/TimeSeriesComboChart/TimeSeriesComboChart.stories.tsx@@ -0,0 +1,142 @@+import { Meta, StoryObj } from '@storybook/react'++import type { Series } from '../../core/types'+import { Stage, useReactiveTheme } from '../../story-helpers'+import { MONTHLY_LABELS } from '../time-series-fixtures'+import { TimeSeriesComboChart } from './TimeSeriesComboChart'++const meta: Meta = {+ title: 'Components/HogCharts/TimeSeriesComboChart',+ parameters: { layout: 'centered' },+}+export default meta++type Story = StoryObj<{}>++const BAR_AND_LINE: Series[] = [+ { key: 'visits', label: 'Visits', data: [120, 135, 150, 142, 200, 220, 245, 260, 275, 290, 310, 330], type: 'bar' },+ {+ key: 'rolling',+ label: 'Rolling avg',+ data: [110, 125, 140, 145, 180, 205, 230, 250, 268, 282, 300, 320],+ type: 'line',+ },+]++export const Basic: Story = {+ render: () => {+ const theme = useReactiveTheme()+ return (+ <Stage>+ <TimeSeriesComboChart+ series={BAR_AND_LINE}+ labels={MONTHLY_LABELS}+ theme={theme}+ config={{+ xAxis: { timezone: 'UTC', interval: 'month' },+ yAxis: { showGrid: true },+ legend: { show: true },+ }}+ />+ </Stage>+ )+ },+}++export const StackedBarsAndLine: Story = {+ render: () => {+ const theme = useReactiveTheme()+ const series: Series[] = [+ {+ key: 'desktop',+ label: 'Desktop',+ data: [70, 80, 90, 85, 120, 130, 145, 150, 160, 170, 185, 195],+ type: 'bar',+ },+ {+ key: 'mobile',+ label: 'Mobile',+ data: [50, 55, 60, 57, 80, 90, 100, 110, 115, 120, 125, 135],+ type: 'bar',+ },+ {+ key: 'total',+ label: 'Total (rolling)',+ data: [120, 135, 150, 142, 200, 220, 245, 260, 275, 290, 310, 330],+ type: 'line',+ },+ ]+ return (+ <Stage>+ <TimeSeriesComboChart+ series={series}+ labels={MONTHLY_LABELS}+ theme={theme}+ config={{+ xAxis: { timezone: 'UTC', interval: 'month' },+ yAxis: { showGrid: true },+ barLayout: 'stacked',+ legend: { show: true },+ }}+ />+ </Stage>+ )+ },+}++/** A goal line above the data range stretches the value axis so it still renders on-plot. */+export const WithGoalLine: Story = {+ render: () => {+ const theme = useReactiveTheme()+ return (+ <Stage>+ <TimeSeriesComboChart+ series={BAR_AND_LINE}+ labels={MONTHLY_LABELS}+ theme={theme}+ config={{+ xAxis: { timezone: 'UTC', interval: 'month' },+ yAxis: { showGrid: true },+ goalLines: [{ value: 400, label: 'Target' }],+ }}+ />+ </Stage>+ )+ },+}++/** Bars on the left axis, a line on the right — independent y-axes. */+export const DualYAxis: Story = {+ render: () => {+ const theme = useReactiveTheme()+ const series: Series[] = [+ {+ key: 'revenue',+ label: 'Revenue',+ data: [1100, 1300, 1250, 1700, 1500, 1900, 1800, 2100, 2200, 2400, 2600, 2800],+ type: 'bar',+ },+ {+ key: 'conversion',+ label: 'Conversion',+ data: [0.022, 0.028, 0.025, 0.034, 0.031, 0.038, 0.036, 0.04, 0.042, 0.045, 0.047, 0.05],+ type: 'line',+ yAxisId: 'right',+ },+ ]+ return (+ <Stage>+ <TimeSeriesComboChart+ series={series}+ labels={MONTHLY_LABELS}+ theme={theme}+ config={{+ xAxis: { timezone: 'UTC', interval: 'month' },+ yAxis: { showGrid: true },+ legend: { show: true },+ }}+ />+ </Stage>+ )+ },+}diff --git a/packages/quill/packages/charts/src/charts/TimeSeriesComboChart/TimeSeriesComboChart.test.tsx b/packages/quill/packages/charts/src/charts/TimeSeriesComboChart/TimeSeriesComboChart.test.tsxnew file mode 100644index 000000000000..ea362387d142--- /dev/null+++ b/packages/quill/packages/charts/src/charts/TimeSeriesComboChart/TimeSeriesComboChart.test.tsx@@ -0,0 +1,319 @@+import { fireEvent } from '@testing-library/react'++import { useChartLayout } from '../../core/chart-context'+import type { ChartTheme, Series } from '../../core/types'+import { getHogChart, renderHogChart, waitForHogChartTooltip } from '../../testing'+import { TimeSeriesComboChart } from './TimeSeriesComboChart'++const THEME: ChartTheme = {+ colors: ['#111', '#222', '#333'],+ backgroundColor: '#ffffff',+}+const LABELS = ['Mon', 'Tue', 'Wed']+const BAR_AND_LINE: Series[] = [+ { key: 'bar', label: 'Bar', data: [40, 60, 50], type: 'bar' },+ { key: 'line', label: 'Line', data: [42, 55, 53], type: 'line' },+]++describe('TimeSeriesComboChart', () => {+ it('renders mixed bar + line series', () => {+ const { chart } = renderHogChart(<TimeSeriesComboChart series={BAR_AND_LINE} labels={LABELS} theme={THEME} />)+ expect(chart.seriesCount).toBe(2)+ expect(chart.yTicks().length).toBeGreaterThan(0)+ })++ describe('config.xAxis', () => {+ it('hides x-axis ticks when xAxis.hide is true', () => {+ const { chart } = renderHogChart(+ <TimeSeriesComboChart+ series={BAR_AND_LINE}+ labels={LABELS}+ theme={THEME}+ config={{ xAxis: { hide: true } }}+ />+ )+ expect(chart.xTicks()).toHaveLength(0)+ })++ it('forwards an explicit xAxis.tickFormatter to the chart', () => {+ const explicit = (_v: string, i: number): string => `tick-${i}`+ const { chart } = renderHogChart(+ <TimeSeriesComboChart+ series={BAR_AND_LINE}+ labels={['14:00', '15:00', '16:00']}+ theme={THEME}+ config={{ xAxis: { tickFormatter: explicit } }}+ />+ )+ expect(chart.xTicks()).toEqual(['tick-0', 'tick-1', 'tick-2'])+ })++ it('builds an auto date formatter from xAxis.timezone + xAxis.interval', () => {+ const labels = ['2024-06-10', '2024-06-11', '2024-06-12']+ const { chart } = renderHogChart(+ <TimeSeriesComboChart+ series={BAR_AND_LINE}+ labels={labels}+ theme={THEME}+ config={{ xAxis: { timezone: 'UTC', interval: 'day' } }}+ />+ )+ const ticks = chart.xTicks()+ expect(ticks.length).toBeGreaterThan(0)+ expect(ticks.some((t) => /Jun \d+/.test(t))).toBe(true)+ })++ it('exposes the resolved formatter to children via ChartLayoutContext', () => {+ let observed: ((value: string, index: number) => string | null) | undefined+ function Probe(): null {+ observed = useChartLayout().axis.xTickFormatter+ return null+ }+ renderHogChart(+ <TimeSeriesComboChart+ series={BAR_AND_LINE}+ labels={['2024-06-10', '2024-06-11', '2024-06-12']}+ theme={THEME}+ config={{ xAxis: { timezone: 'UTC', interval: 'day' } }}+ >+ <Probe />+ </TimeSeriesComboChart>+ )+ const formatter = observed as (value: string, index: number) => string | null+ expect(formatter('2024-06-10', 0)).toMatch(/Jun \d+|June/)+ })+ })++ describe('config.yAxis', () => {+ it('hides y-axis ticks when yAxis.hide is true', () => {+ const { chart } = renderHogChart(+ <TimeSeriesComboChart+ series={BAR_AND_LINE}+ labels={LABELS}+ theme={THEME}+ config={{ yAxis: { hide: true } }}+ />+ )+ expect(chart.yTicks()).toHaveLength(0)+ })++ it.each([+ [{ format: 'percentage' as const }, /\d+%$/],+ [{ prefix: '$', suffix: ' req' }, /^\$.* req$/],+ ])('builds a y-axis tick formatter from yAxis %p', (yAxis, pattern) => {+ const { chart } = renderHogChart(+ <TimeSeriesComboChart series={BAR_AND_LINE} labels={LABELS} theme={THEME} config={{ yAxis }} />+ )+ expect(chart.yTicks().some((t) => pattern.test(t))).toBe(true)+ })++ it('explicit yAxis.tickFormatter wins over yAxis.format', () => {+ const explicit = (v: number): string => `y:${v}`+ const { chart } = renderHogChart(+ <TimeSeriesComboChart+ series={BAR_AND_LINE}+ labels={LABELS}+ theme={THEME}+ config={{ yAxis: { tickFormatter: explicit, format: 'percentage' } }}+ />+ )+ expect(chart.yTicks().every((t) => t.startsWith('y:'))).toBe(true)+ })+ })++ describe('config.goalLines', () => {+ it('does not render reference lines when config is omitted', () => {+ const { chart } = renderHogChart(+ <TimeSeriesComboChart series={BAR_AND_LINE} labels={LABELS} theme={THEME} />+ )+ expect(chart.referenceLines()).toHaveLength(0)+ })++ it('does not render reference lines when goalLines is empty', () => {+ const { chart } = renderHogChart(+ <TimeSeriesComboChart series={BAR_AND_LINE} labels={LABELS} theme={THEME} config={{ goalLines: [] }} />+ )+ expect(chart.referenceLines()).toHaveLength(0)+ })++ it('renders horizontal goal lines with their label', () => {+ const { chart } = renderHogChart(+ <TimeSeriesComboChart+ series={BAR_AND_LINE}+ labels={LABELS}+ theme={THEME}+ config={{ goalLines: [{ value: 50, label: 'Target' }] }}+ />+ )+ const lines = chart.referenceLines()+ expect(lines).toHaveLength(1)+ expect(lines[0].orientation).toBe('horizontal')+ expect(lines[0].label).toBe('Target')+ })++ it('extends the value axis so a goal line above the data still renders', () => {+ const { chart } = renderHogChart(+ <TimeSeriesComboChart+ series={[{ key: 'b', label: 'B', data: [10, 20, 30], type: 'bar' }]}+ labels={LABELS}+ theme={THEME}+ config={{ goalLines: [{ value: 1000, label: 'Target' }] }}+ />+ )+ expect(chart.referenceLines()).toHaveLength(1)+ })+ })++ describe('config.valueLabels', () => {+ it('does not render value labels when config is omitted', () => {+ const { chart } = renderHogChart(+ <TimeSeriesComboChart series={BAR_AND_LINE} labels={LABELS} theme={THEME} />+ )+ expect(chart.valueLabels()).toHaveLength(0)+ })++ it('does not render value labels when valueLabels is false', () => {+ const { chart } = renderHogChart(+ <TimeSeriesComboChart+ series={BAR_AND_LINE}+ labels={LABELS}+ theme={THEME}+ config={{ valueLabels: false }}+ />+ )+ expect(chart.valueLabels()).toHaveLength(0)+ })++ it('forwards an explicit formatter', () => {+ const formatter = (v: number): string => `~${v}`+ const { chart } = renderHogChart(+ <TimeSeriesComboChart+ series={[{ key: 'bar', label: 'Bar', data: [1, 2, 3], type: 'bar' }]}+ labels={LABELS}+ theme={THEME}+ config={{ valueLabels: { formatter } }}+ />+ )+ expect(chart.valueLabels().map((l) => l.text)).toEqual(['~1', '~2', '~3'])+ })+ })++ describe('config.barLayout', () => {+ // Two bar series (per-band sums up to 55) plus a small line, so the bars — not the line —+ // drive the value axis and stacked vs grouped produce a visibly different y-domain top.+ const STACKABLE: Series[] = [+ { key: 'a', label: 'A', data: [10, 20, 30], type: 'bar' },+ { key: 'b', label: 'B', data: [5, 15, 25], type: 'bar' },+ { key: 'l', label: 'L', data: [1, 1, 1], type: 'line' },+ ]+ const maxTick = (ticks: string[]): number => Math.max(...ticks.map(Number))++ it('stacks bar segments so the y-axis spans the stacked total', () => {+ const { chart } = renderHogChart(+ <TimeSeriesComboChart+ series={STACKABLE}+ labels={LABELS}+ theme={THEME}+ config={{ barLayout: 'stacked' }}+ />+ )+ expect(maxTick(chart.yTicks())).toBeGreaterThanOrEqual(55)+ })++ it('groups bars so the y-axis spans only the tallest single value', () => {+ const { chart } = renderHogChart(+ <TimeSeriesComboChart+ series={STACKABLE}+ labels={LABELS}+ theme={THEME}+ config={{ barLayout: 'grouped' }}+ />+ )+ expect(maxTick(chart.yTicks())).toBeLessThan(55)+ })+ })++ it('renders a right axis when a series sets yAxisId: right', () => {+ const series: Series[] = [+ { key: 'b', label: 'Revenue', data: [1000, 2000, 1500], type: 'bar' },+ { key: 'l', label: 'Conv', data: [0.02, 0.03, 0.025], type: 'line', yAxisId: 'right' },+ ]+ const { chart } = renderHogChart(<TimeSeriesComboChart series={series} labels={LABELS} theme={THEME} />)+ expect(chart.hasRightAxis).toBe(true)+ expect(chart.yRightTicks().length).toBeGreaterThan(0)+ })++ it('forwards children alongside built-in overlays', () => {+ const { container } = renderHogChart(+ <TimeSeriesComboChart series={BAR_AND_LINE} labels={LABELS} theme={THEME}>+ <div data-attr="custom-overlay" />+ </TimeSeriesComboChart>+ )+ expect(container.querySelector('[data-attr="custom-overlay"]')).not.toBeNull()+ })++ describe('hover & tooltip', () => {+ it('lists every visible series at the hovered x', async () => {+ const { chart } = renderHogChart(+ <TimeSeriesComboChart series={BAR_AND_LINE} labels={LABELS} theme={THEME} />+ )+ chart.hoverAtIndex(1)+ const tooltip = await chart.waitForTooltip()+ expect(tooltip.seriesData.map((s) => s.series.key).sort()).toEqual(['bar', 'line'])+ })++ // `nativeTooltip` lets the chart render its own DefaultTooltip from config (the harness's+ // default tooltip-prop interception would otherwise bypass the config formatters).+ it('formats the built-in tooltip rows with config.tooltip.valueFormatter', async () => {+ const { chart } = renderHogChart(+ <TimeSeriesComboChart+ series={BAR_AND_LINE}+ labels={LABELS}+ theme={THEME}+ config={{ tooltip: { valueFormatter: (v) => `$${v}` } }}+ />,+ { nativeTooltip: true }+ )+ chart.hoverAtIndex(1)+ const tooltip = await waitForHogChartTooltip()+ expect(tooltip.textContent).toContain('$60')+ })++ it('appends a total row when config.tooltip.showTotal is set', async () => {+ const { chart } = renderHogChart(+ <TimeSeriesComboChart+ series={BAR_AND_LINE}+ labels={LABELS}+ theme={THEME}+ config={{ tooltip: { showTotal: true, totalLabel: 'Sum' } }}+ />,+ { nativeTooltip: true }+ )+ chart.hoverAtIndex(1)+ const tooltip = await waitForHogChartTooltip()+ expect(tooltip.textContent).toContain('Sum')+ })+ })++ describe('interactive legend', () => {+ it('toggles a series off and on when its legend row is clicked', () => {+ const { container, chart } = renderHogChart(+ <TimeSeriesComboChart+ series={BAR_AND_LINE}+ labels={LABELS}+ theme={THEME}+ config={{ legend: { show: true } }}+ />+ )+ expect(chart.seriesCount).toBe(2)+ const buttons = (): HTMLButtonElement[] =>+ Array.from(container.querySelectorAll('[data-attr="hog-chart-timeseries-combo-legend"] button'))++ fireEvent.click(buttons()[1])+ expect(getHogChart(container).seriesCount).toBe(1)++ fireEvent.click(buttons()[1])+ expect(getHogChart(container).seriesCount).toBe(2)+ })+ })+})diff --git a/packages/quill/packages/charts/src/charts/TimeSeriesComboChart/TimeSeriesComboChart.tsx b/packages/quill/packages/charts/src/charts/TimeSeriesComboChart/TimeSeriesComboChart.tsxnew file mode 100644index 000000000000..50439edf8584--- /dev/null+++ b/packages/quill/packages/charts/src/charts/TimeSeriesComboChart/TimeSeriesComboChart.tsx@@ -0,0 +1,151 @@+import React, { useMemo } from 'react'++import { ChartLegend } from '../../components/Legend/ChartLegend'+import { useChartLegend } from '../../components/Legend/useChartLegend'+import type {+ ChartLegendConfig,+ ChartTheme,+ ComboChartConfig,+ PointClickData,+ SeriesType,+ Series,+ TooltipConfig,+ TooltipContext,+} from '../../core/types'+import { ReferenceLines } from '../../overlays/ReferenceLine'+import { ValueLabels } from '../../overlays/ValueLabels'+import { buildGoalLineReferenceLines, goalLineValueDomain, type GoalLineConfig } from '../../utils/goal-lines'+import {+ useXTickFormatter,+ useYTickFormatter,+ type XAxisConfig,+ type YAxisConfig,+} from '../../utils/use-axis-formatters'+import { ComboChart } from '../ComboChart/ComboChart'+import {+ resolveValueLabelsConfig,+ useSeriesWithValueLabelAllowlist,+ type ValueLabelsConfig,+} from '../utils/use-value-labels'++export interface TimeSeriesComboChartConfig {+ xAxis?: XAxisConfig+ yAxis?: YAxisConfig+ valueLabels?: boolean | ValueLabelsConfig+ goalLines?: GoalLineConfig[]+ /** Type used for series that don't set {@link Series.type}. Defaults to `'line'`. */+ defaultSeriesType?: SeriesType+ /** Layout applied to *bar* series only — lines and areas never stack or group. Defaults to+ * `'stacked'`. */+ barLayout?: ComboChartConfig['barLayout']+ /** Stacked bars only round the topmost segment. */+ barCornerRadius?: number+ /** Show a vertical crosshair line that follows the cursor. */+ showCrosshair?: boolean+ /** Draw L-shaped axis baselines without grid lines (ignored when `yAxis.showGrid` is true). */+ showAxisLines?: boolean+ /** Tooltip behaviour (pinning, placement). Tooltip *content* is the `tooltip` render prop. */+ tooltip?: TooltipConfig+ /** Built-in legend with click-to-toggle series visibility. Hidden by default. */+ legend?: ChartLegendConfig+}++export interface TimeSeriesComboChartProps<Meta = unknown> {+ series: Series<Meta>[]+ labels: string[]+ theme: ChartTheme+ config?: TimeSeriesComboChartConfig+ tooltip?: (ctx: TooltipContext<Meta>) => React.ReactNode+ onPointClick?: (data: PointClickData<Meta>) => void+ dataAttr?: string+ className?: string+ children?: React.ReactNode+ onError?: (error: Error, info: React.ErrorInfo) => void+}++/** Time-indexed {@link ComboChart}: mixed bar + line/area series on a timezone/interval-aware band+ * x-axis, plus the time-series chrome `ComboChart` lacks — date x-axis, goal lines, a built-in+ * legend, and value labels. Mirrors {@link TimeSeriesBarChart}/{@link TimeSeriesLineChart}. */+export function TimeSeriesComboChart<Meta = unknown>({+ series,+ labels,+ theme,+ config,+ tooltip,+ onPointClick,+ dataAttr,+ className,+ children,+ onError,+}: TimeSeriesComboChartProps<Meta>): React.ReactElement {+ const {+ xAxis,+ yAxis,+ valueLabels,+ goalLines,+ defaultSeriesType,+ barLayout,+ barCornerRadius,+ showCrosshair,+ showAxisLines,+ tooltip: tooltipConfig,+ legend,+ } = config ?? {}+ const xTickFormatter = useXTickFormatter(xAxis, labels)+ const yTickFormatter = useYTickFormatter(yAxis)++ const { visibleSeries, legendProps } = useChartLegend(series, theme, legend)++ const valueLabelsConfig = resolveValueLabelsConfig(valueLabels)+ const seriesAfterValueLabels = useSeriesWithValueLabelAllowlist(visibleSeries, valueLabelsConfig?.seriesKeys)++ const valueLabelFormatter = valueLabelsConfig ? (valueLabelsConfig.formatter ?? yTickFormatter) : undefined++ const referenceLines = useMemo(+ () => buildGoalLineReferenceLines(goalLines, seriesAfterValueLabels),+ [goalLines, seriesAfterValueLabels]+ )++ // Extend the value axis to cover goal lines that sit outside the data range, so a goal line+ // off the data's natural scale still renders inside the plot. Memoized so the `{ include }`+ // object stays referentially stable and doesn't re-trigger scale recomputation each render.+ const valueDomain = useMemo(() => goalLineValueDomain(referenceLines), [referenceLines])++ const comboChartConfig: ComboChartConfig = {+ yScaleType: yAxis?.scale,+ xTickFormatter,+ yTickFormatter,+ hideXAxis: xAxis?.hide,+ hideYAxis: yAxis?.hide,+ xAxisLabel: xAxis?.label,+ yAxisLabel: yAxis?.label,+ showGrid: yAxis?.showGrid,+ showAxisLines,+ showCrosshair,+ defaultSeriesType,+ barLayout,+ barCornerRadius,+ tooltip: tooltipConfig,+ valueDomain,+ }++ return (+ <ChartLegend {...legendProps} legendDataAttr="hog-chart-timeseries-combo-legend">+ <ComboChart+ series={seriesAfterValueLabels}+ labels={labels}+ config={comboChartConfig}+ theme={theme}+ tooltip={tooltip}+ onPointClick={onPointClick}+ className={className}+ dataAttr={dataAttr}+ onError={onError}+ >+ {referenceLines.length > 0 && <ReferenceLines lines={referenceLines} />}+ {valueLabelsConfig && <ValueLabels valueFormatter={valueLabelFormatter} />}+ {children}+ </ComboChart>+ </ChartLegend>+ )+}diff --git a/packages/quill/packages/charts/src/core/Chart.tsx b/packages/quill/packages/charts/src/core/Chart.tsxindex 8f85ed609b57..2e7aaa346b32 100644--- a/packages/quill/packages/charts/src/core/Chart.tsx+++ b/packages/quill/packages/charts/src/core/Chart.tsx@@ -97,7 +97,7 @@ export function Chart<Meta = unknown>({createScales: createScalesFn,drawStatic,drawHover,- tooltip: renderTooltip = DefaultTooltip,+ tooltip: renderTooltipProp,onPointClick,onDateRangeZoom,className,@@ -160,8 +160,28 @@ export function Chart<Meta = unknown>({enabled: showTooltip = true,pinnable: pinnableTooltip = false,placement: tooltipPlacement = 'follow-data',+ valueFormatter: tooltipValueFormatter,+ showTotal: tooltipShowTotal,+ totalLabel: tooltipTotalLabel,+ totalFormatter: tooltipTotalFormatter,} = tooltipConfig ?? {}+ // No render prop: render DefaultTooltip with config.tooltip's formatters (all undefined → bare default).+ const renderTooltip = useMemo<(ctx: TooltipContext<Meta>) => React.ReactNode>(+ () =>+ renderTooltipProp ??+ ((ctx: TooltipContext<Meta>) => (+ <DefaultTooltip+ {...ctx}+ valueFormatter={tooltipValueFormatter}+ showTotal={tooltipShowTotal}+ totalLabel={tooltipTotalLabel}+ totalFormatter={tooltipTotalFormatter}+ />+ )),+ [renderTooltipProp, tooltipValueFormatter, tooltipShowTotal, tooltipTotalLabel, tooltipTotalFormatter]+ )+const margins = useChartMargins({series,labels,diff --git a/packages/quill/packages/charts/src/core/combo-scales.ts b/packages/quill/packages/charts/src/core/combo-scales.tsindex 79916715dee6..c5573f6ab122 100644--- a/packages/quill/packages/charts/src/core/combo-scales.ts+++ b/packages/quill/packages/charts/src/core/combo-scales.ts@@ -1,15 +1,7 @@import { scaleBand, type ScaleBand } from 'd3-scale'-import {- buildValueScale,- type D3YScale,- groupVisibleSeriesByAxis,- orderedAxisPositions,- seriesValueRange,- type StackedBand,- yTickCountForHeight,-} from './scales'-import type { ChartDimensions, Series, SeriesType } from './types'+import { createYScale, type D3YScale, groupVisibleSeriesByAxis, orderedAxisPositions, type StackedBand } from './scales'+import type { ChartDimensions, Series, SeriesType, ValueDomain } from './types'import { DEFAULT_Y_AXIS_ID } from './types'/** Combo chart scale set — a band x-axis plus per-axis value scales spanning every series on@@ -44,6 +36,9 @@ export interface CreateComboScalesOptions {seriesTypeOf: (series: Series) => SeriesType/** Stacked-band data for bar series. Required when `barLayout` is `'stacked'`. */barStackedData?: Map<string, StackedBand>+ /** Applied to the primary (default/left) axis only — goal lines (`{ include }`) render against+ * the primary axis, so secondary axes keep their own data-derived scale. See {@link ValueDomain}. */+ valueDomain?: ValueDomain}export function resolveSeriesType(series: Pick<Series, 'type'>, defaultType: SeriesType): SeriesType {@@ -67,6 +62,7 @@ export function createComboScales(groupPadding = 0.1,seriesTypeOf,barStackedData,+ valueDomain,} = optionsconst band = scaleBand<string>()@@ -83,14 +79,15 @@ export function createComboScales(group = scaleBand<string>().domain(barKeys).range([0, band.bandwidth()]).padding(groupPadding)}- const tickCount = yTickCountForHeight(dimensions.plotHeight)- const valueRange: [number, number] = [dimensions.plotTop + dimensions.plotHeight, dimensions.plotTop]-// Empty chart still needs an axis to draw against.const axisPositions = orderedAxisPositions(series)if (axisPositions.length === 0) {axisPositions.push({ axisId: DEFAULT_Y_AXIS_ID, position: 'left' })}+ const primaryAxisId = axisPositions.some((a) => a.axisId === DEFAULT_Y_AXIS_ID)+ ? DEFAULT_Y_AXIS_ID+ : axisPositions[0].axisId+const seriesByAxis = groupVisibleSeriesByAxis(series)const yAxes: ComboScaleSet['yAxes'] = {}for (const { axisId, position } of axisPositions) {@@ -104,30 +101,20 @@ export function createComboScales(}return s})- yAxes[axisId] = { scale: buildComboValueScale(axisValueSeries, valueRange, tickCount, scaleType), position }+ // `createYScale` applies the shared overlay baseline clamp, degenerate `min === max`+ // guard, log fallback, and `{ include }` goal-line domain extension — primary axis only.+ const scale = createYScale(axisValueSeries, dimensions, {+ scaleType,+ valueDomain: axisId === primaryAxisId ? valueDomain : undefined,+ })+ yAxes[axisId] = { scale, position }}- const primaryAxisId = axisPositions.some((a) => a.axisId === DEFAULT_Y_AXIS_ID)- ? DEFAULT_Y_AXIS_ID- : axisPositions[0].axisIdconst primary = yAxes[primaryAxisId].scalereturn { band, group, yAxes, y: primary, value: primary }}-function buildComboValueScale(- series: Series[],- valueRange: [number, number],- tickCount: number,- scaleType: 'linear' | 'log'-): D3YScale {- const range = seriesValueRange(series)- const primaryRange = series.some((s) => s.overlay) ? seriesValueRange(series.filter((s) => !s.overlay)) : range- // Shares `createYScale`'s overlay baseline clamp, degenerate `min === max` guard, and log- // fallback — see `buildValueScale`.- return buildValueScale({ range, primaryRange, valueRange, tickCount, scaleType })-}-/** Partition visible series into bar vs line/area buckets, preserving input order within each* bucket. Excluded series are dropped. */export function partitionByType<S extends Pick<Series, 'visibility'>>(diff --git a/packages/quill/packages/charts/src/core/types.ts b/packages/quill/packages/charts/src/core/types.tsindex 799888c23dc5..37aaaaf73b77 100644--- a/packages/quill/packages/charts/src/core/types.ts+++ b/packages/quill/packages/charts/src/core/types.ts@@ -288,7 +288,7 @@ export interface ChartLegendConfig {}export interface TooltipConfig {- /** Show a tooltip on hover. Defaults to true. Use the `tooltip` render prop on Chart to customize content. */+ /** Show a tooltip on hover. Defaults to true. */enabled?: boolean/** When true, clicking a data point with multiple series pins the tooltip in place. */pinnable?: boolean@@ -297,6 +297,13 @@ export interface TooltipConfig {* as the cursor moves between data points; `cursor` tracks the mouse, so the tooltip sits* beside the cursor and the hovered bar (chart.js-style) rather than at a fixed anchor. */placement?: 'follow-data' | 'top' | 'cursor'+ // Built-in DefaultTooltip content, applied only when no `tooltip` render prop is given. See+ // DefaultTooltipProps for semantics — these mirror it.+ /** Second arg is the row's `seriesData` entry, for per-series formatting. */+ valueFormatter?: (value: number, entry: TooltipContext['seriesData'][number]) => string+ showTotal?: boolean+ totalLabel?: string+ totalFormatter?: (value: number) => string}/** How the value axis domain is determined (y for vertical/line/area charts, x for horizontal@@ -395,6 +402,9 @@ export interface ComboChartConfig extends Omit<ChartConfig, 'axisOrientation'> {barLayout?: 'stacked' | 'grouped'/** Corner radius for the cap of bar segments. Stacked bars only round the topmost segment. */barCornerRadius?: number+ /** Value-axis domain control for the primary axis — omit for data-derived auto-scaling. Used+ * to keep off-scale goal lines on-plot (`{ include }`). See {@link ValueDomain}. */+ valueDomain?: ValueDomain}/** Arguments passed to a chart type's canvas draw function. */diff --git a/packages/quill/packages/charts/src/index.ts b/packages/quill/packages/charts/src/index.tsindex 209931fb4b19..b945638db32a 100644--- a/packages/quill/packages/charts/src/index.ts+++ b/packages/quill/packages/charts/src/index.ts@@ -16,6 +16,11 @@ export type {export type { ValueLabelsConfig } from './charts/utils/use-value-labels'export { TimeSeriesBarChart } from './charts/TimeSeriesBarChart/TimeSeriesBarChart'export type { TimeSeriesBarChartConfig, TimeSeriesBarChartProps } from './charts/TimeSeriesBarChart/TimeSeriesBarChart'+export { TimeSeriesComboChart } from './charts/TimeSeriesComboChart/TimeSeriesComboChart'+export type {+ TimeSeriesComboChartConfig,+ TimeSeriesComboChartProps,+} from './charts/TimeSeriesComboChart/TimeSeriesComboChart'export { Sparkline } from './charts/Sparkline/Sparkline'export type { SparklineProps } from './charts/Sparkline/Sparkline'export { MetricCard } from './components/MetricCard/MetricCard'