: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): dash patterns for grid lines and the hover crosshair (#67994)
Sam Pennington1e12c50c33a7
diff --git a/packages/quill/packages/charts/AGENTS.md b/packages/quill/packages/charts/AGENTS.mdindex e5a5084845ae..2e8f0f917533 100644--- a/packages/quill/packages/charts/AGENTS.md+++ b/packages/quill/packages/charts/AGENTS.md@@ -30,7 +30,7 @@ const theme = useChartTheme() // reads CSS vars, tracks light/dark switches- Series colors come from `--data-color-1..15` (ordered categorical palette from `@posthog/quill-tokens`); chrome from `--color-graph-axis-label` / `--color-graph-axis-line` / `--color-graph-crosshair`.- `themeFromCssVars()` is the one-shot non-hook version; `DEFAULT_CHART_COLORS` is the no-DOM fallback (kept in sync with tokens by a CI-enforced test).- Omit `color` on a series to get palette assignment by index — preferred. Explicit `color` accepts hex or `var(--...)`.-- Restyle knobs, all optional and off by default so themes/hosts opt in: `theme.axisLineColor` strokes the L-axis baselines and tick marks without changing tick-label text color (falls back `axisColor` → `gridColor`). Config side: `showAxisLines` draws the L-axis (alongside the grid; the grid then skips its own frame and category lines), `showTickMarks` draws short canvas tick marks snapped to the same pixel grid as the axis, and `curve: 'monotone'` smooths line/area series through every point without overshoot. With axis lines on, line strokes are trimmed at the y-axis and floored onto the x-axis so they rest against the axis instead of straddling it.+- Restyle knobs, all optional and off by default so themes/hosts opt in: `theme.axisLineColor` strokes the L-axis baselines and tick marks without changing tick-label text color (falls back `axisColor` → `gridColor`); `theme.gridDashPattern` / `theme.crosshairDashPattern` (e.g. `[3, 3]`) dash the interior grid lines / hover crosshair (plot-edge frame strokes stay solid). Config side: `showAxisLines` draws the L-axis (alongside the grid; the grid then skips its own frame and category lines), `showTickMarks` draws short canvas tick marks snapped to the same pixel grid as the axis, and `curve: 'monotone'` smooths line/area series through every point without overshoot. With axis lines on, line strokes are trimmed at the y-axis and floored onto the x-axis so they rest against the axis instead of straddling it.- `theme.skipDraw` suppresses all canvas painting (static layer + hover overlay) while still mounting the `<canvas>` element. Use it for deterministic visual-snapshot tests where the async paint pipeline (ResizeObserver → requestAnimationFrame) races the screenshot — the chart renders blank but layout and DOM selectors are unaffected.## Series shape (all multi-series charts)diff --git a/packages/quill/packages/charts/src/charts/BarChart/utils/draw-bar-chart.ts b/packages/quill/packages/charts/src/charts/BarChart/utils/draw-bar-chart.tsindex 52fd6a3fb707..c29cf6493fc5 100644--- a/packages/quill/packages/charts/src/charts/BarChart/utils/draw-bar-chart.ts+++ b/packages/quill/packages/charts/src/charts/BarChart/utils/draw-bar-chart.ts@@ -124,6 +124,7 @@ export function drawBarChartStatic(if (showGrid) {drawGrid(baseDrawCtx, {gridColor: theme.gridColor,+ gridDash: theme.gridDashPattern,frame: !showAxisLines,orientation: isHorizontal ? 'horizontal' : 'vertical',// In the axis-line style only the value-axis grid guides reading; category linesdiff --git a/packages/quill/packages/charts/src/charts/BoxPlot/BoxPlot.tsx b/packages/quill/packages/charts/src/charts/BoxPlot/BoxPlot.tsxindex f95360aedc4a..7a24009543d5 100644--- a/packages/quill/packages/charts/src/charts/BoxPlot/BoxPlot.tsx+++ b/packages/quill/packages/charts/src/charts/BoxPlot/BoxPlot.tsx@@ -238,7 +238,11 @@ function BoxPlotInner<Meta = unknown>({}if (showGrid) {- drawGrid(baseDrawCtx, { gridColor: theme.gridColor, orientation: 'vertical' })+ drawGrid(baseDrawCtx, {+ gridColor: theme.gridColor,+ gridDash: theme.gridDashPattern,+ orientation: 'vertical',+ })}for (const s of coloredSeries) {diff --git a/packages/quill/packages/charts/src/charts/ComboChart/ComboChart.tsx b/packages/quill/packages/charts/src/charts/ComboChart/ComboChart.tsxindex 0373d169ebd3..a5c545df6fd5 100644--- a/packages/quill/packages/charts/src/charts/ComboChart/ComboChart.tsx+++ b/packages/quill/packages/charts/src/charts/ComboChart/ComboChart.tsx@@ -195,7 +195,12 @@ function ComboChartInner<Meta = unknown>({: computeVisibleXLabels(drawLabels, (label) => bandCenter(comboScales, label), xTickFormatter).map((entry) => entry.x)- drawGrid(baseDrawCtx, { gridColor: theme.gridColor, frame: !showAxisLines, categoryTicks })+ drawGrid(baseDrawCtx, {+ gridColor: theme.gridColor,+ gridDash: theme.gridDashPattern,+ frame: !showAxisLines,+ categoryTicks,+ })}// ── 1. Bars ──────────────────────────────────────────────────────────────────────diff --git a/packages/quill/packages/charts/src/charts/LineChart/LineChart.tsx b/packages/quill/packages/charts/src/charts/LineChart/LineChart.tsxindex 83b25611ad01..3d01219b1bfd 100644--- a/packages/quill/packages/charts/src/charts/LineChart/LineChart.tsx+++ b/packages/quill/packages/charts/src/charts/LineChart/LineChart.tsx@@ -189,7 +189,7 @@ function LineChartInner<Meta = unknown>({// Grid sits behind the data; the L-axis is drawn after the series (below) so the line// doesn't paint over the baseline where it meets the axis.if (showGrid) {- drawGrid(baseDrawCtx, { gridColor: theme.gridColor, frame: !showAxisLines })+ drawGrid(baseDrawCtx, { gridColor: theme.gridColor, gridDash: theme.gridDashPattern, frame: !showAxisLines })}// Area then line+points per series, clipped vertically (shared with ComboChart). Areas usediff --git a/packages/quill/packages/charts/src/core/Chart.tsx b/packages/quill/packages/charts/src/core/Chart.tsxindex a4d0656d8c22..1b8ff8ddd2b7 100644--- a/packages/quill/packages/charts/src/core/Chart.tsx+++ b/packages/quill/packages/charts/src/core/Chart.tsx@@ -318,12 +318,13 @@ export function Chart<Meta = unknown>({const composedDrawHover = useMemo(() => {const withCrosshair = composeDrawHoverWithCrosshair(() => drawHoverRef.current, {crosshairColor: theme.crosshairColor,+ crosshairDash: theme.crosshairDashPattern,showCrosshair,axisOrientation,labelToCoord,})return composeDrawHoverWithSelection(withCrosshair)- }, [showCrosshair, theme.crosshairColor, axisOrientation, labelToCoord, drawHoverRef.current])+ }, [showCrosshair, theme.crosshairColor, theme.crosshairDashPattern, axisOrientation, labelToCoord, drawHoverRef.current])useChartDraw({ctx,diff --git a/packages/quill/packages/charts/src/core/canvas-renderer.test.ts b/packages/quill/packages/charts/src/core/canvas-renderer.test.tsindex e219eb97948d..29a71e9750ec 100644--- a/packages/quill/packages/charts/src/core/canvas-renderer.test.ts+++ b/packages/quill/packages/charts/src/core/canvas-renderer.test.ts@@ -793,6 +793,19 @@ describe('hog-charts canvas-renderer', () => {})})+ describe('drawGrid — dash pattern', () => {+ it.each(['vertical', 'horizontal'] as const)(+ '%s orientation: dashes interior grid lines while the frame strokes stay solid',+ (orientation) => {+ const ctx = mockCanvasContext()+ drawGrid(makeDrawContext(ctx, ['a', 'b']), { gridDash: [3, 3], orientation })+ const patterns = dashCalls(ctx)+ expect(patterns[0]).toEqual([3, 3])+ expect(patterns[patterns.length - 1]).toEqual([])+ }+ )+ })+describe('drawGrid', () => {it('draws a horizontal line at the first y-tick (vertical orientation)', () => {const ctx = mockCanvasContext()@@ -906,6 +919,17 @@ describe('hog-charts canvas-renderer', () => {expect(drawHover).toHaveBeenCalledTimes(1)})+ it('dashes the crosshair with crosshairDash and resets to solid for subsequent hover drawing', () => {+ const ctx = mockCanvasContext()+ const composed = composeDrawHoverWithCrosshair(() => jest.fn(), {+ crosshairColor: '#f00',+ crosshairDash: [3, 3],+ showCrosshair: true,+ })+ composed(makeArgs(ctx, 1, 200))+ expect(dashCalls(ctx)).toEqual([[3, 3], []])+ })+it('skips crosshair when showCrosshair is false', () => {const ctx = mockCanvasContext()const composed = composeDrawHoverWithCrosshair(() => jest.fn(), {diff --git a/packages/quill/packages/charts/src/core/canvas-renderer.ts b/packages/quill/packages/charts/src/core/canvas-renderer.tsindex 39f682e140dc..bd7da8b91078 100644--- a/packages/quill/packages/charts/src/core/canvas-renderer.ts+++ b/packages/quill/packages/charts/src/core/canvas-renderer.ts@@ -670,6 +670,9 @@ export function drawTickMarks(export interface DrawGridOptions {gridColor?: string+ /** Canvas dash pattern (e.g. `[3, 3]`) for the interior grid lines. Solid when omitted.+ * The plot-edge baseline strokes stay solid either way — only the interior lines dash. */+ gridDash?: number[]/** Draw the solid plot-edge baseline strokes framing the grid (both value-axis edges).* Defaults to true. Charts drawing their own axis lines pass false — the L-axis replaces the* near baseline, and the far one would read as a stray border. */@@ -700,7 +703,7 @@ export function drawGrid(drawCtx: DrawContext, options: DrawGridOptions = {}): vctx.strokeStyle = gridColorctx.lineWidth = 1- ctx.setLineDash([])+ ctx.setLineDash(options.gridDash ?? [])// Skip the first category tick when it falls right next to the axis baseline// (left edge in vertical mode, top edge in horizontal) — otherwise it renders@@ -731,6 +734,7 @@ export function drawGrid(drawCtx: DrawContext, options: DrawGridOptions = {}): vctx.lineTo(dimensions.plotLeft + dimensions.plotWidth, y)ctx.stroke()}+ ctx.setLineDash([])if (frame) {const axisY = snapToPixel(dimensions.plotTop)ctx.beginPath()@@ -774,6 +778,7 @@ export function drawGrid(drawCtx: DrawContext, options: DrawGridOptions = {}): vctx.stroke()}+ ctx.setLineDash([])if (frame) {const axisX = snapToPixel(dimensions.plotLeft)ctx.beginPath()@@ -796,13 +801,14 @@ export function drawCrosshair(dimensions: ChartDimensions,coord: number,color: string,- orientation: 'vertical' | 'horizontal' = 'vertical'+ orientation: 'vertical' | 'horizontal' = 'vertical',+ dash?: number[]): void {// 0.5 offset keeps the 1px line crisp on integer pixel boundaries.const line = Math.round(coord) + 0.5ctx.strokeStyle = colorctx.lineWidth = 1- ctx.setLineDash([])+ ctx.setLineDash(dash ?? [])ctx.beginPath()if (orientation === 'vertical') {ctx.moveTo(line, dimensions.plotTop)@@ -812,6 +818,7 @@ export function drawCrosshair(ctx.lineTo(dimensions.plotLeft + dimensions.plotWidth, line)}ctx.stroke()+ ctx.setLineDash([])}export interface BarRoundedCorners {@@ -1312,6 +1319,7 @@ type DrawHoverFn = (args: ChartDrawArgs) => DrawHoverResultinterface ComposeDrawHoverOptions {crosshairColor: string | undefined+ crosshairDash?: number[]showCrosshair: booleanaxisOrientation?: 'vertical' | 'horizontal'labelToCoord?: (label: string) => number | undefined@@ -1322,13 +1330,13 @@ export function composeDrawHoverWithCrosshair(getDrawHover: () => DrawHoverFn,options: ComposeDrawHoverOptions): DrawHoverFn {- const { crosshairColor, showCrosshair, axisOrientation = 'vertical', labelToCoord } = options+ const { crosshairColor, crosshairDash, showCrosshair, axisOrientation = 'vertical', labelToCoord } = optionsreturn (args) => {if (showCrosshair && crosshairColor && args.hoverIndex >= 0) {const label = args.labels[args.hoverIndex]const coord = labelToCoord ? labelToCoord(label) : args.scales.x(label)if (coord != null && isFinite(coord)) {- drawCrosshair(args.ctx, args.dimensions, coord, crosshairColor, axisOrientation)+ drawCrosshair(args.ctx, args.dimensions, coord, crosshairColor, axisOrientation, crosshairDash)}}return getDrawHover()(args)diff --git a/packages/quill/packages/charts/src/core/types.ts b/packages/quill/packages/charts/src/core/types.tsindex c7c808db6514..dc0d212a6ba5 100644--- a/packages/quill/packages/charts/src/core/types.ts+++ b/packages/quill/packages/charts/src/core/types.ts@@ -11,7 +11,11 @@ export interface ChartTheme {* then `gridColor` — set it to mute the lines without muting the tick label text. */axisLineColor?: stringgridColor?: string+ /** Canvas dash pattern (e.g. `[3, 3]`) for interior grid lines. Solid when omitted. */+ gridDashPattern?: number[]crosshairColor?: string+ /** Canvas dash pattern (e.g. `[3, 3]`) for the hover crosshair. Solid when omitted. */+ crosshairDashPattern?: number[]tooltipBackground?: stringtooltipColor?: stringtooltipZIndex?: number | string