: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(quill-charts): honor axis bounds on combo axes without bars (#125542)
Ben White0ef6ecf75703
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 0409c467c15c..90b03480a2e8 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -1552,6 +1552,10 @@ snapshots:hash: v1.k794b7964.66f0d459b4954743f10f429a64e3e7f6a74b26aaf42896449ee98ec5b8a5e783.bMjI6PrvYtjTBFJBN_l9tquTCL9z2MiPiACCyg7NwpMcomponents-hogcharts-timeseriesbarchart--y-axis-formats--light:hash: v1.k794b7964.f0589ce149310d1a832ccc2db09eda5cca7b0bb18684e05d094edaa6273cc72b.6lIAqygaq9W2YE6ENM_VZc6_V_xrukW5donVRn_sX2I+ components-hogcharts-timeseriescombochart--axis-bounds-without-bars--dark:+ hash: v1.k794b7964.46d2c2b260b332ca0bc639111ff7adb33435d4844ee0b20d34a6afef02013be7.NYBntcdtOnz1-00Onx60m6Suzq8IswvupfKOvA8ZPDU+ components-hogcharts-timeseriescombochart--axis-bounds-without-bars--light:+ hash: v1.k794b7964.549e7973b6641ef3c2718dec2e0df528c7b75cfcca2e12deb05856c655bd5b6a.LhtSK2b7lEnRpGzPPQBAj7ZJ0i_K3wEWMGvBmXj_klIcomponents-hogcharts-timeseriescombochart--basic--dark:hash: v1.k794b7964.01ebf62eb35e385cd89a00bcf3207570c252e7b6bca8acdbfe9e88841747679f.lIbb4yy1TrccNA96voGPROTbdr61LQRAsE1jcm-x1accomponents-hogcharts-timeseriescombochart--basic--light:diff --git a/packages/quill/packages/charts/AGENTS.md b/packages/quill/packages/charts/AGENTS.mdindex c69e4291fae5..7657249af681 100644--- a/packages/quill/packages/charts/AGENTS.md+++ b/packages/quill/packages/charts/AGENTS.md@@ -97,7 +97,7 @@ Charts fill their container and need a parent with real dimensions — a zero-he- A duplicate label draws the series backwards. Use ISO dates, not display labels.- In percent layouts every formatter receives a 0..1 fraction; `ValueLabelContext.rawValue` has the original.-- Bar and combo charts ignore `yAxis.min` / `max` on purpose. Pin `valueDomain` instead.+- Bar charts, and combo axes carrying bars, ignore `yAxis.min` / `max` on purpose. Pin the primary axis's `valueDomain` instead.- A pinned tooltip's `onRowClick` only fires when `config.tooltip.pinnable` is set. Call `ctx.onUnpin()` before opening a modal from it.- On stacked bars, describe the hovered segment from `TooltipContext.hoveredSeriesKey`, not `seriesData[0]`.- A secondary axis with a fixed meaning (0..1, 0..100) needs `min` / `max` pinned, or a reference line above its data falls off the plot.diff --git a/packages/quill/packages/charts/src/charts/ComboChart/ComboChart.tsx b/packages/quill/packages/charts/src/charts/ComboChart/ComboChart.tsxindex 1b0429924e46..cc3a0d75c438 100644--- a/packages/quill/packages/charts/src/charts/ComboChart/ComboChart.tsx+++ b/packages/quill/packages/charts/src/charts/ComboChart/ComboChart.tsx@@ -105,6 +105,8 @@ function ComboChartInner<Meta = unknown>({defaultSeriesType = DEFAULT_SERIES_TYPE,xTickFormatter,valueDomain,+ valueBounds,+ floatBaseline = false,curve,yAxes: configYAxes,} = config ?? {}@@ -153,6 +155,8 @@ function ComboChartInner<Meta = unknown>({bandPadding: config?.bandPadding,groupPadding: config?.bandPadding === 0 ? 0 : undefined,valueDomain,+ valueBounds,+ floatBaseline,axes: configYAxes,})@@ -186,7 +190,17 @@ function ComboChartInner<Meta = unknown>({_private: comboPrivate,}},- [yScaleType, barLayout, seriesTypeOf, barStackedData, valueDomain, configYAxes, config?.bandPadding]+ [+ yScaleType,+ barLayout,+ seriesTypeOf,+ barStackedData,+ valueDomain,+ valueBounds,+ floatBaseline,+ configYAxes,+ config?.bandPadding,+ ])const drawStatic = useCallback(diff --git a/packages/quill/packages/charts/src/charts/TimeSeriesComboChart/TimeSeriesComboChart.stories.tsx b/packages/quill/packages/charts/src/charts/TimeSeriesComboChart/TimeSeriesComboChart.stories.tsxindex f7a31e9dc4bf..e6912142e646 100644--- a/packages/quill/packages/charts/src/charts/TimeSeriesComboChart/TimeSeriesComboChart.stories.tsx+++ b/packages/quill/packages/charts/src/charts/TimeSeriesComboChart/TimeSeriesComboChart.stories.tsx@@ -161,3 +161,31 @@ export const DualYAxis: Story = {)},}++/** `yAxis.min` / `max` apply to axes that carry no bars. Here the bars sit on the left axis from+ * zero, while the right axis (lines only) is bounded to 100..350 to zoom in on the variation. */+export const AxisBoundsWithoutBars: Story = {+ render: () => {+ const theme = useReactiveTheme()+ return (+ <Stage>+ <TimeSeriesComboChart+ series={[+ { ...BAR_AND_LINE[0], yAxisId: 'left' },+ { ...BAR_AND_LINE[1], yAxisId: 'right' },+ ]}+ labels={MONTHLY_LABELS}+ theme={theme}+ config={{+ xAxis: { timezone: 'UTC', interval: 'month' },+ yAxis: [+ { id: 'left', showGrid: true, min: 200 },+ { id: 'right', position: 'right', min: 100, max: 350 },+ ],+ 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.tsxindex 66feeb66acba..32163fa04045 100644--- a/packages/quill/packages/charts/src/charts/TimeSeriesComboChart/TimeSeriesComboChart.test.tsx+++ b/packages/quill/packages/charts/src/charts/TimeSeriesComboChart/TimeSeriesComboChart.test.tsx@@ -119,6 +119,19 @@ describe('TimeSeriesComboChart', () => {expect(Math.max(...ticks)).toBe(100)})+ const AREAS = BAR_AND_LINE.map((s) => ({ ...s, type: 'area' as const }))+ it.each([+ ['ignores yAxis.min on an axis with bars', BAR_AND_LINE, { min: 30 }, 0],+ ['honors yAxis.min on an axis without bars', AREAS, { min: 30 }, 30],+ ['ignores startAtZero: false on an axis with bars', BAR_AND_LINE, { startAtZero: false }, 0],+ ['honors startAtZero: false on an axis without bars', AREAS, { startAtZero: false }, 40],+ ])('%s', (_, series, yAxis, expectedMinTick) => {+ const { chart } = renderChart(+ <TimeSeriesComboChart series={series} labels={LABELS} theme={THEME} config={{ yAxis }} />+ )+ expect(Math.min(...chart.yTicks().map(Number))).toBe(expectedMinTick)+ })+it('hides y-axis ticks when yAxis.hide is true', () => {const { chart } = renderChart(<TimeSeriesComboChartdiff --git a/packages/quill/packages/charts/src/charts/TimeSeriesComboChart/TimeSeriesComboChart.tsx b/packages/quill/packages/charts/src/charts/TimeSeriesComboChart/TimeSeriesComboChart.tsxindex 1d4458608c67..68f6e773e8d3 100644--- a/packages/quill/packages/charts/src/charts/TimeSeriesComboChart/TimeSeriesComboChart.tsx+++ b/packages/quill/packages/charts/src/charts/TimeSeriesComboChart/TimeSeriesComboChart.tsx@@ -20,7 +20,7 @@ import { mergeValueDomains, type GoalLineConfig } from '../../utils/goal-lines'import { useTimeSeriesTooltipConfig, type XAxisConfig, type YAxisConfig } from '../../utils/use-axis-formatters'import { ComboChart } from '../ComboChart/ComboChart'import { useTrendLineSeries, type TrendLineConfig } from '../utils/use-derived-series'-import { useGoalLines, useTimeSeries } from '../utils/use-time-series'+import { useGoalLines, useTimeSeries, useValueBounds } from '../utils/use-time-series'import type { ValueLabelsConfig } from '../utils/use-value-labels'export interface TimeSeriesComboChartConfig {@@ -134,6 +134,7 @@ export function TimeSeriesComboChart<Meta = unknown>({)const trendSeries = useTrendLineSeries(visibleSeries, trendLines)+ const valueBounds = useValueBounds(primaryYAxis)const comboChartConfig: ComboChartConfig = {margins,@@ -157,6 +158,8 @@ export function TimeSeriesComboChart<Meta = unknown>({bandPadding,tooltip: timeSeriesTooltipConfig,valueDomain,+ valueBounds,+ floatBaseline: primaryYAxis?.startAtZero === false && primaryYAxis?.scale !== 'log',yAxes,}diff --git a/packages/quill/packages/charts/src/core/bar-scales.test.ts b/packages/quill/packages/charts/src/core/bar-scales.test.tsindex f22e79327025..2985a65ac53e 100644--- a/packages/quill/packages/charts/src/core/bar-scales.test.ts+++ b/packages/quill/packages/charts/src/core/bar-scales.test.ts@@ -253,6 +253,15 @@ describe('hog-charts bar scales', () => {expect(isFinite(max)).toBe(true)expect(min).toBeLessThan(max)})++ it('keeps a log scale when both ends are positive', () => {+ const series = [makeSeries({ key: 's1', data: [1, 10, 100] })]+ const { value } = createBarScales(series, ['a', 'b', 'c'], dimensions, {+ scaleType: 'log',+ valueDomain: { min: 1, max: 100 },+ })+ expect(value(10)).toBeCloseTo((value(1) + value(100)) / 2)+ })})describe('createBarScales — log scale', () => {diff --git a/packages/quill/packages/charts/src/core/combo-scales.test.ts b/packages/quill/packages/charts/src/core/combo-scales.test.tsindex 7164ddbf24bc..e96f67b319ac 100644--- a/packages/quill/packages/charts/src/core/combo-scales.test.ts+++ b/packages/quill/packages/charts/src/core/combo-scales.test.ts@@ -177,18 +177,61 @@ describe('combo-scales', () => {expect(scales.yAxes.right.position).toBe('right')})- it('floats a line-only axis with startAtZero false but keeps bar axes on a zero baseline', () => {- const bar = makeSeries({ key: 'bar', data: [800, 1000], type: 'bar' })- const line = makeSeries({ key: 'line', data: [800, 1000], type: 'line', yAxisId: 'right' })+ it.each<[string, string, Partial<Parameters<typeof createComboScales>[3]>, [number, number] | 'floated']>([+ [+ 'floats a line-only axis with startAtZero false',+ 'right',+ {+ axes: [+ { id: DEFAULT_Y_AXIS_ID, position: 'left', startAtZero: false },+ { id: 'right', position: 'right', startAtZero: false },+ ],+ },+ 'floated',+ ],+ [+ 'floats a line-only primary axis with floatBaseline',+ DEFAULT_Y_AXIS_ID,+ { floatBaseline: true },+ 'floated',+ ],+ [+ 'applies valueBounds to a line-only primary axis',+ DEFAULT_Y_AXIS_ID,+ { valueBounds: { min: 500, max: 2000 } },+ [500, 2000],+ ],+ [+ 'applies a secondary axis min/max to a line-only axis',+ 'right',+ { axes: [{ id: 'right', valueDomain: { min: 500, max: 2000 } }] },+ [500, 2000],+ ],+ ])('%s, but keeps the bar axis on a zero baseline', (_, lineAxisId, options, expectedLineDomain) => {+ const barAxisId = lineAxisId === 'right' ? DEFAULT_Y_AXIS_ID : 'right'+ const bar = makeSeries({ key: 'bar', data: [800, 1000], type: 'bar', yAxisId: barAxisId })+ const line = makeSeries({ key: 'line', data: [800, 1000], type: 'line', yAxisId: lineAxisId })const scales = createComboScales([bar, line], ['a', 'b'], dimensions, {seriesTypeOf: typeOfWithDefault('line'),- axes: [- { id: DEFAULT_Y_AXIS_ID, position: 'left', startAtZero: false },- { id: 'right', position: 'right', startAtZero: false },- ],+ ...options,+ })+ expect(scales.yAxes[barAxisId].scale.domain()[0]).toBe(0)+ const lineDomain = scales.yAxes[lineAxisId].scale.domain()+ if (expectedLineDomain === 'floated') {+ expect(lineDomain[0]).toBeGreaterThan(0)+ } else {+ expect(lineDomain).toEqual(expectedLineDomain)+ }+ })++ it('keeps each axis its own bounds when the primary axis has no visible series', () => {+ const line = makeSeries({ key: 'line', data: [800, 1000], type: 'line', yAxisId: 'right' })+ const scales = createComboScales([line], ['a', 'b'], dimensions, {+ seriesTypeOf: typeOfWithDefault('line'),+ valueBounds: { min: 0, max: 10 },+ axes: [{ id: DEFAULT_Y_AXIS_ID }, { id: 'right', valueDomain: { min: 500, max: 2000 } }],})- expect(scales.yAxes[DEFAULT_Y_AXIS_ID].scale.domain()[0]).toBe(0)- expect(scales.yAxes.right.scale.domain()[0]).toBeGreaterThan(0)+ expect(scales.yAxes.right.scale.domain()).toEqual([500, 2000])})it('points combo.y at the default axis when present', () => {diff --git a/packages/quill/packages/charts/src/core/combo-scales.ts b/packages/quill/packages/charts/src/core/combo-scales.tsindex 53d218598d45..e2beaf7e3898 100644--- a/packages/quill/packages/charts/src/core/combo-scales.ts+++ b/packages/quill/packages/charts/src/core/combo-scales.ts@@ -1,5 +1,6 @@import { scaleBand, type ScaleBand } from 'd3-scale'+import { mergeValueDomains } from '../utils/goal-lines'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'@@ -39,9 +40,20 @@ export interface CreateComboScalesOptions {/** 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+ /** Primary-axis `min` / `max`, applied only while the axis carries no bar series. */+ valueBounds?: Pick<ValueDomain, 'min' | 'max'>+ /** Float the primary axis to its data range. Ignored while the axis carries bar series. */+ floatBaseline?: boolean/** Per-axis overrides — explicit values win over the alternating-side default and- * `options.scaleType`. `startAtZero: false` is ignored for axes carrying bar series. */- axes?: { id: string; position?: 'left' | 'right'; scaleType?: 'linear' | 'log'; startAtZero?: boolean }[]+ * `options.scaleType`. `startAtZero: false` and the `valueDomain` bounds are ignored for axes+ * carrying bar series. */+ axes?: {+ id: string+ position?: 'left' | 'right'+ scaleType?: 'linear' | 'log'+ startAtZero?: boolean+ valueDomain?: ValueDomain+ }[]}export function resolveSeriesType(series: Pick<Series, 'type'>, defaultType: SeriesType): SeriesType {@@ -66,6 +78,8 @@ export function createComboScales(seriesTypeOf,barStackedData,valueDomain,+ valueBounds,+ floatBaseline = false,axes,} = options@@ -96,6 +110,16 @@ export function createComboScales(? DEFAULT_Y_AXIS_ID: axisPositions[0].axisId+ // `valueBounds` and `floatBaseline` belong to the configured primary axis (the default id, else+ // the first configured axis), which keeps them when legend toggling hides its series. This is+ // deliberately not `primaryAxisId`: `valueDomain` carries goal-line `include`s, which follow the+ // first visible axis.+ const boundsAxisId = axes?.length+ ? axisOverrides.has(DEFAULT_Y_AXIS_ID)+ ? DEFAULT_Y_AXIS_ID+ : axes[0].id+ : primaryAxisId+const seriesByAxis = groupVisibleSeriesByAxis(series)const yAxes: ComboScaleSet['yAxes'] = {}for (const { axisId, position } of axisPositions) {@@ -120,12 +144,24 @@ export function createComboScales(// Percent-clamp only axes that actually carry bar series — a line/area-only axis (e.g. a// series explicitly routed to the right axis) keeps its own data-derived scale instead of// being forced onto [0, 1].+ // A bar encodes magnitude as length from zero, so axis bounds and a floating baseline only+ // apply to axes without bars.const hasBarSeries = axisSeries.some((s) => seriesTypeOf(s) === 'bar')+ const override = axisOverrides.get(axisId)+ const isBoundsAxis = axisId === boundsAxisId+ let axisDomain = axisId === primaryAxisId ? valueDomain : undefined+ if (!hasBarSeries) {+ axisDomain = mergeValueDomains(+ axisDomain,+ mergeValueDomains(override?.valueDomain, isBoundsAxis ? valueBounds : undefined)+ )+ }+ const startAtZero = override?.startAtZero ?? (isBoundsAxis ? !floatBaseline : true)const scale = createYScale(axisValueSeries, dimensions, {- scaleType: axisOverrides.get(axisId)?.scaleType ?? scaleType,+ scaleType: override?.scaleType ?? scaleType,percentStack: barLayout === 'percent' && hasBarSeries,- valueDomain: axisId === primaryAxisId ? valueDomain : undefined,- floatBaseline: !hasBarSeries && axisOverrides.get(axisId)?.startAtZero === false,+ valueDomain: axisDomain,+ floatBaseline: !hasBarSeries && !startAtZero,})yAxes[axisId] = { scale, position }}diff --git a/packages/quill/packages/charts/src/core/scales.test.ts b/packages/quill/packages/charts/src/core/scales.test.tsindex 7a7ceec3b350..22619d931788 100644--- a/packages/quill/packages/charts/src/core/scales.test.ts+++ b/packages/quill/packages/charts/src/core/scales.test.ts@@ -253,6 +253,22 @@ describe('hog-charts scales', () => {expect(scale.domain()).toEqual([0, 40])})+ // A log domain can't hold zero, so a non-positive end is dropped and the axis stays logarithmic.+ it.each([+ ['both ends positive', { min: 1, max: 100 }],+ ['a zero min', { min: 0, max: 100 }],+ ])('keeps a log scale with %s', (_name, valueDomain) => {+ const series = [makeSeries({ key: 's1', data: [1, 10, 100] })]+ const scale = createYScale(series, dimensions, { scaleType: 'log', valueDomain })+ expect(scale(10)).toBeCloseTo((scale(1) + scale(100)) / 2)+ })++ it('maps a value past a pinned log domain off the plot, so overlays can hide it', () => {+ const series = [makeSeries({ key: 's1', data: [1, 10, 100] })]+ const scale = createYScale(series, dimensions, { scaleType: 'log', valueDomain: { min: 1, max: 100 } })+ expect(scale(1000)).toBeLessThan(dimensions.plotTop)+ })+it('takes precedence over percent stack mode', () => {const series = [makeSeries({ key: 's1', data: [10, 20, 30] })]const scale = createYScale(series, dimensions, { percentStack: true, valueDomain: { min: 0, max: 200 } })diff --git a/packages/quill/packages/charts/src/core/scales.ts b/packages/quill/packages/charts/src/core/scales.tsindex 54bc1bfef3fc..980fe7a6e6f8 100644--- a/packages/quill/packages/charts/src/core/scales.ts+++ b/packages/quill/packages/charts/src/core/scales.ts@@ -78,7 +78,10 @@ export function seriesValueRange(series: Series[]): SeriesValueRange {/** Split a {@link ValueDomain} into a pinned `[min, max]` (both ends given) and the adjustments to* an auto-scaled domain (either end left open). An inverted pair is dropped rather than swapped;* see {@link ValueDomain}. */-function resolveValueDomain(valueDomain: ValueDomain | undefined): {+function resolveValueDomain(+ valueDomain: ValueDomain | undefined,+ log = false+): {fixed?: readonly [number, number]include?: readonly number[]bounds?: ValueDomain@@ -90,7 +93,9 @@ function resolveValueDomain(valueDomain: ValueDomain | undefined): {const min = usableBound(valueDomain.min)const max = usableBound(valueDomain.max)- if (min !== undefined && max !== undefined) {+ // A log domain can't hold zero, so a pair with a non-positive end stays a clamp on the auto+ // domain, where `applyValueBounds` drops that end if the axis really is logarithmic.+ if (min !== undefined && max !== undefined && (!log || min > 0)) {// Both ends pinned, so `include` has nothing left to stretch.return min < max ? { fixed: [min, max] } : { include }}@@ -240,6 +245,20 @@ function repairDegenerateExtent(min: number, max: number): [number, number] {return [lo, Math.max(0, isFinite(max) ? max : 0, lo + 1)]}+/** A value scale over a pinned `[min, max]`. A log domain can't hold zero, so a log pin with a+ * non-positive end falls back to linear. Unclamped, like the linear pin, so a value past the pin+ * maps off the plot and overlays such as goal lines can tell it is out of range. */+function fixedValueScale(+ fixed: readonly [number, number],+ range: [number, number],+ scaleType: 'linear' | 'log'+): D3YScale {+ if (scaleType === 'log' && fixed[0] > 0) {+ return scaleLog().domain(fixed).range(range)+ }+ return scaleLinear().domain(sanitizeFixedDomain(fixed)).range(range)+}+export function createYScale(series: Series[],dimensions: ChartDimensions,@@ -253,13 +272,11 @@ export function createYScale(} = {}): ScaleLinear<number, number> | ScaleLogarithmic<number, number> {const { scaleType = 'linear', percentStack = false, valueDomain, floatBaseline = false } = options- const { fixed, include, bounds } = resolveValueDomain(valueDomain)+ const { fixed, include, bounds } = resolveValueDomain(valueDomain, scaleType === 'log')const tickCount = yTickCountForHeight(dimensions.plotHeight)if (fixed) {- return scaleLinear()- .domain(sanitizeFixedDomain(fixed))- .range([dimensions.plotTop + dimensions.plotHeight, dimensions.plotTop])+ return fixedValueScale(fixed, [dimensions.plotTop + dimensions.plotHeight, dimensions.plotTop], scaleType)}if (percentStack) {@@ -833,7 +850,7 @@ function buildBarValueScale(): D3YScale {const { fixed, include } = resolveValueDomain(valueDomain)if (fixed) {- return scaleLinear().domain(sanitizeFixedDomain(fixed)).range(valueRange)+ return fixedValueScale(fixed, valueRange, scaleType)}if (barLayout === 'percent') {return scaleLinear().domain([0, 1]).nice(tickCount).range(valueRange)diff --git a/packages/quill/packages/charts/src/core/types.ts b/packages/quill/packages/charts/src/core/types.tsindex 9ce79b768072..e7c1e8e8db5c 100644--- a/packages/quill/packages/charts/src/core/types.ts+++ b/packages/quill/packages/charts/src/core/types.ts@@ -552,6 +552,13 @@ export interface ComboChartConfig extends Omit<ChartConfig, 'axisOrientation'> {/** 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+ /** Primary-axis `min` / `max`, honored only while that axis carries no bar series: a bar encodes+ * magnitude as length from zero, so a raised floor would misread it. Use `valueDomain` to rescale+ * an axis with bars. `valueDomain` wins a bound both set. */+ valueBounds?: Pick<ValueDomain, 'min' | 'max'>+ /** Float the primary axis to its data range instead of clamping the baseline to 0. Ignored while+ * the axis carries bar series, and on a log scale. Defaults to false. */+ floatBaseline?: boolean}/** Arguments passed to a chart type's canvas draw function. */diff --git a/packages/quill/packages/charts/src/docs/axes.md b/packages/quill/packages/charts/src/docs/axes.mdindex 31084887b9ed..6311dff7bd8c 100644--- a/packages/quill/packages/charts/src/docs/axes.md+++ b/packages/quill/packages/charts/src/docs/axes.md@@ -45,12 +45,12 @@ Duration formatters accept seconds (`duration`), milliseconds (`duration_ms`), o## Baseline and range-- The y-axis clamps a non-negative axis down to 0 by default. To float it to the data range, set `yAxis.startAtZero: false` on `TimeSeriesLineChart`, or `config.floatBaseline: true` on the lower-level `LineChart`. Ignored on a log scale and applied to the primary axis only. Bar charts always draw from zero.+- The y-axis clamps a non-negative axis down to 0 by default. To float it to the data range, set `yAxis.startAtZero: false` on `TimeSeriesLineChart` or `TimeSeriesComboChart`, or `config.floatBaseline: true` on the lower-level `LineChart` and `ComboChart`. Ignored on a log scale and applied to the primary axis only. Bar charts, and combo axes that carry bars, always draw from zero.- `yAxis.min` and `max` pin either end on `TimeSeriesLineChart` (`config.valueDomain: { min, max }` on `LineChart`, the same option that carries `include`). Both set pins the axis: skips `nice()`, discards `include`, overrides percent layout. One set clamps that end and leaves the other automatic; it runs after `include` folding, the zero clamp, and `nice()`, so only the extreme label is the raw bound while interior ticks stay round. A single clamp is ignored under a percent layout, where the domain is already 0..1.- On a log scale a non-positive bound is dropped. A non-finite bound counts as unset, so `{ min: 0, max: Math.max(...[]) }` floors at zero rather than collapsing. An inverted `min >= max` pair falls back to the automatic domain rather than swapping.- `TimeSeriesLineChart` also accepts `config.valueDomain` for shared bounds and `include` values. Explicit domain bounds take precedence over `yAxis.min/max`; include values merge with reference-line extents.- Overlays positioned off the value scale hide themselves outside a bounded window rather than painting over the chrome: a goal line drops out, and so does the value label of a clipped point. A point sitting exactly on the bound keeps its label.-- Bar and combo charts ignore `min` and `max` even though they take the same `yAxis` config. A bar encodes magnitude as length from zero, so a bounded baseline misreads it: 10 vs 11 would draw as 1 vs 2. Pin `valueDomain` there instead, which rescales the bars rather than truncating them. `TimeSeriesBarChart` and `TimeSeriesComboChart` take `config.valueDomain`; setting both `min` and `max` skips `nice()` and wins over the goal-line stretch. Pin `{ min: 0, max: dataMax }` so the tallest bar reaches the plot top on an axis-less volume chart, where nice-rounded headroom is invisible waste. `include` merges with the goal-line stretch (`mergeValueDomains` in `utils/goal-lines.ts`).+- Bar charts ignore `min` and `max` even though they take the same `yAxis` config, and so does a combo-chart axis that carries bar series. A combo axis with only lines and areas honors them, and `startAtZero: false`, like the line chart (`config.valueBounds` and `config.floatBaseline` on the lower-level `ComboChart`). A bar encodes magnitude as length from zero, so a bounded baseline misreads it: 10 vs 11 would draw as 1 vs 2. Pin the primary axis's `valueDomain` there instead, which rescales the bars rather than truncating them. A secondary bar axis can't be rescaled. `TimeSeriesBarChart` and `TimeSeriesComboChart` take `config.valueDomain`; setting both `min` and `max` skips `nice()` and wins over the goal-line stretch. Pin `{ min: 0, max: dataMax }` so the tallest bar reaches the plot top on an axis-less volume chart, where nice-rounded headroom is invisible waste. `include` merges with the goal-line stretch (`mergeValueDomains` in `utils/goal-lines.ts`).## Multiple y-axesdiff --git a/packages/quill/packages/charts/src/utils/use-axis-formatters.ts b/packages/quill/packages/charts/src/utils/use-axis-formatters.tsindex a8331481bca9..d7c242e82ea9 100644--- a/packages/quill/packages/charts/src/utils/use-axis-formatters.ts+++ b/packages/quill/packages/charts/src/utils/use-axis-formatters.ts@@ -34,14 +34,12 @@ export interface YAxisConfig extends YFormatterConfig {showGrid?: boolean/** Y-axis baseline behavior. The default (`undefined`/`true`) clamps a non-negative axis down to* 0. Set `false` to float the axis to its data range instead (zoom in on the variation). Ignored- * on a log scale; honored per axis in the array (multi-axis) form, except axes carrying bar- * series, which always draw from 0. */+ * on a log scale; honored per axis, except on axes carrying bar series, which always draw from 0. */startAtZero?: boolean/** Pins the low end of the axis, overriding both the data-derived bound and `startAtZero`. Omit* for an automatic bound. Honored per axis in the array (multi-axis) form; ignored under a- * percent layout, and dropped when non-positive on a log scale. Read by the line charts only:- * this config is shared, but bar and combo charts ignore it, since a bar encodes magnitude as- * length from zero. */+ * percent layout, and dropped when non-positive on a log scale. Bar charts, and combo-chart axes+ * carrying bar series, ignore it, since a bar encodes magnitude as length from zero. */min?: number/** Pins the high end of the axis. Omit for an automatic bound. See {@link YAxisConfig.min}. */max?: number