: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(charts): give box plots a cleaner, rounded style (#120996)
Sam Pennington354c4b741223
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 45392d2da0f9..dddcfa7a4aae 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -1069,29 +1069,29 @@ snapshots:components-hogcharts-barlist--wide-with-one-long-label--light:hash: v1.k794b7964.163c8a1058bf5f2bf1d5cf8a1bde53ad2cc1f23a31b04ba44d149d346f950e92.B-juvp5CdUQ8hpm9Ryg-PYqcKww9Rrrl7pcJhLlswLMcomponents-hogcharts-boxplot--horizontal--dark:- hash: v1.k794b7964.30cbeacc1f375b50732dd7c20765bbedfc0dc626d4896c8fa9687aa5f9bfc001.FTUzztXbfM9Du-zf-HPWGeBiY0cPJRqb3Ybj7dYNln8+ hash: v1.k794b7964.bd5f1e2c1ff28597ce68efa819ae92a7d5bb2edf1e45652e41e8640a319e2d87.SLz9oJ46_MW6d5vkmhXkaGwfS5vxIVo7iAL_FGdWIZ8components-hogcharts-boxplot--horizontal--light:- hash: v1.k794b7964.aec9e9c2b045f52ff9c7b439bc22260f45ca59a8965a8086ba9150aea221edd4.JkVfjROZzhUJfai3iKOmQmvmcOSY92m5tKg24b65qpA+ hash: v1.k794b7964.f58ca4dcbfc5f6ff25d83fa9f400e7d4407ed3700583c97affa8afaffbda45d6._sHl6m0uor1JlEenZXSTmEuMv_t5-IhACNLBvAZxCM0components-hogcharts-boxplot--horizontal-log-scale--dark:- hash: v1.k794b7964.3ac079cae9db4bd2deb288342d8954ccd11e58a34e8e0cb8fc6ec92dfb82b1b1.Gm5cGG6ZEsju02uwqNvHF62mtJuI7Poo7cA_VCxmjHg+ hash: v1.k794b7964.ed08b1a84a97eac36b9719406ea93471c285bed8b91a15f485e4e346fe7a8ba8.TZ8z39z_KnVA1oEg11c0gUAhiF69ONSKIgtYgeQon_scomponents-hogcharts-boxplot--horizontal-log-scale--light:- hash: v1.k794b7964.f4b58820e4955ee8d26de3cb2f9e743c3ff5f7cbfe94253ed95d7fce11b0fe51.47EN0L76m4Tszagv7IimkYbuVmbTOj3OHAkbertIvuA+ hash: v1.k794b7964.b966d47bbf649843c7df91edc0e18fff0fcc61e20e7bda3efb789c9fe1ec4a43.sg1QshvoodRNv_ZNtELqciToDJcvMwJpkxOc3KH7Df4components-hogcharts-boxplot--multi-series-grouped--dark:- hash: v1.k794b7964.fd8a8c11e35ef420a663807a21a6349eba0ae2658c6c3d114763f4629dd45934.d23KBypemM2QY55g8_QWVUc9diJoAL1oNZjK3d3Ebs4+ hash: v1.k794b7964.0ac7b4f0dcfa6bbc0ee3a58e146b4d5a685ebcc454eefc7b807315ecd942cc06.McPV7RBnpQ67hIHYLs68kddSglbehC8zwp5AzpcRQBMcomponents-hogcharts-boxplot--multi-series-grouped--light:- hash: v1.k794b7964.016f9887360412c0b22e1b45e677ab2c289961ce86382e4bb7287f7d8c5dd110.cuv1S6OAl-253E0RJgLwIzHtVxH1ji5mzIOT3GTBWnk+ hash: v1.k794b7964.f278ac945a2fe808a51c1b5206327b0d2e393ced3c136299c9d98a98ea40f91e.hmcP3C_STttETPNhSrMUjtXJyp61fH4BIrBDJtCFgRscomponents-hogcharts-boxplot--no-grid--dark:- hash: v1.k794b7964.ec49b9672a800158cc0dd7f1a517dfec0912d03ce7bc8b56c9a08492fdef723f.5tbdsdN5AB0mtLjoNobhw1skLsS4m5Sc6Es7TSdhTWg+ hash: v1.k794b7964.9738bd5ec36fd30fdae7ed73e6baf0d05916fac325cb35c5b9a11721ccdae423.MIVVz_WeaCzyVAFh2GgLIUvqGdAzjgLVbsMhO5ttAYccomponents-hogcharts-boxplot--no-grid--light:- hash: v1.k794b7964.0acf72ad47f9a19ce05636173f88556ed6295e047e837b40efbb843a313e2aba.CFuhDsheSmTtAEXlWPHwYcm71sF3bhU7lUnSjdmq5rQ+ hash: v1.k794b7964.49bf242236a9905132b23be763e2b7408bef24288a0aa2eb3fd267dceeacddf0.G5dZKIvu-RhgYB8KOoloPjcRLgFfVs2ZG42dtWX4sVAcomponents-hogcharts-boxplot--single-series--dark:- hash: v1.k794b7964.6b626ce7e92fbbbefedfb6a9f1871c94bbfe64099c50ea7d0a5269825556e233.r196EOIFwsIKTg8FRXsT8iHrf3-VCfHtFJLNXGPWGV8+ hash: v1.k794b7964.c6be9871b584f2de40380e60dd8a77a2fb1780012ed83a88f66012f0f6635ce0.GDRQ_RcN1yoSZzVG8D_4q0aNRG5uKO-ofgCHvZBJZrscomponents-hogcharts-boxplot--single-series--light:- hash: v1.k794b7964.2a2fa9e8444df2904ea5eab272941c651550a278a4bc67d94700b68982d7068d.pDbCOJRyh31JQL3epxSJjo_qiw8i4ZGBUMXcR6eQuzQ+ hash: v1.k794b7964.9fb0e7affe69d2881d452df2ecba98217380a62e17525b7a681c71470d14b22e.1c9Uc6Bmc560tOLyZPn_mHTsSTfW4v61jY7Gp1cMriIcomponents-hogcharts-boxplot--with-gaps--dark:- hash: v1.k794b7964.1bb749585227fbc2d0f4906182ffc670f47e6e5a2a24b814f0c6cb1503f5a30b.4zIJdm__aD7xg-er5nnvxZice_LwlDQ-41cum9dZyMQ+ hash: v1.k794b7964.08027703367494f3c74a806482d88214748847670007744b91af0f4813fc1398.4N5mIOqZ_BPmq1VVQEhBIBkWSscLDeknd_1pq-_lHtkcomponents-hogcharts-boxplot--with-gaps--light:- hash: v1.k794b7964.40456eed26029114ecb4197c38519d3171efc4036a167cab25037ee399cb9f10.zWfS4HjZw3ke-_LCm_LIUOxJbGE-SFceGerI5je1p1M+ hash: v1.k794b7964.dc58e19eb893eeb88523c21662390fbd5a62a1c51e446302eefcc2fc8f8f7f1b.fMw4xTRBan4MXzJ8Kyp4dEW4T2RnXp8NMoO7oGe6zJkcomponents-hogcharts-combochart--area-and-line--dark:hash: v1.k794b7964.eade395e5b05a394a5353c135e5cdac1e360935ee70947cc5b011ae8a8092f9c.F7Nd0J12GUFBkR9MLr3V7JTX_ID7-cKl-kUD1qKn1wwcomponents-hogcharts-combochart--area-and-line--light:@@ -3825,9 +3825,9 @@ snapshots:insights-boldnumber--empty-result--light:hash: v1.k794b7964.2d0c17643991833246321ec917a7b3a49228fb7b217b6bdb8742bbebe1164a5d.bFD6Zu0IU06yXEaw5GNlDjBhvFh8vqBKvXRQwCS53gsinsights-boxplot--default--dark:- hash: v1.k794b7964.0703a7022dee7396b3f005ebe10aeb376345086ef4c7fc2458108ce87351123d.Ps1FFHDhHcNR2ApWX_ypYngS_xpINJtwB9EH-9n8vLU+ hash: v1.k794b7964.2355c82ed442c788a592b52eb843bdce6f46a0271bc536a15b7bf55302cf2334.UE5P0FwOP8iHexSKvoYWRTNpgz0TzaZjOnWRaq-_Kmwinsights-boxplot--default--light:- hash: v1.k794b7964.0e1fc3799ec1876e6ccca4da11c8ebc63836acbe5cbe7453912a385be0564dc5.Pxd_3RMZ6szO03ZwKl6_6UT1AW7TiK_1WllTaLSn60k+ hash: v1.k794b7964.386541e90a9caed4d5865519bbad75b61fc18096753958a99f50c3014a87d045.6ReLt-7ysRwo_ihjIAbS6r3gwjTpx3wlFeIgDzS8joQinsights-funnelbarhorizontalchart--breakdown--dark:hash: v1.k794b7964.ac5a15d1e2bb0e43d045a7927294882e733e23559dcaeb06d8ac6c1ebeb48755.SKkzdF8SPOh_RniQ11S8oDGsTTtKXko93TINN3LV4gwinsights-funnelbarhorizontalchart--breakdown--light:@@ -12639,9 +12639,9 @@ snapshots:scenes-app-insights-sqlboxplot--edit-options--light:hash: v1.k794b7964.1539a8a8d4d19728490331fac7430332d2e1bbac19da9ed11ad6d571976e7864.2fmBRJA-TEOHgC7ODM42naay_EdDGTMjFH9HQFYfbLcscenes-app-insights-sqlboxplot--grouped-series--dark:- hash: v1.k794b7964.0062f9e095cb6266619d2886be6973be68c7fc906f50d8b37064390de6757656.frURXaRskPxT8wSqipNvLkFVNmgq3uiSKORwD_fLWDA+ hash: v1.k794b7964.e8e02705d2c2c04c95c28531323ac3afda9177a46f6d3207f1566faa0bdb357d.3VyKBqkXAnxXNZufZ_HlYp7q3M3J3E2go7zXqIPKQzEscenes-app-insights-sqlboxplot--grouped-series--light:- hash: v1.k794b7964.d6214c2e48859cedc4c7dc30552657668a7e9a1a7f92f4643b3d2dbe56df2d57.ytDzXwguLj-27G1jRP28BG-bv7d6q1z4CgNsAmbpqgw+ hash: v1.k794b7964.2f522e5e4d16f1470b99c8c98c21842cbf5a39c988263cb13dc57a3706f018b7.M2SkT7clbB2liQpcqR7Sx-18zQLJZ25bC5jIgXFQB9wscenes-app-insights-sqllinechart--sql-bar-chart-value-labels-quill--dark:hash: v1.k794b7964.482f71c0aadde604594294d6e723590838e5b47f543adf3baf39c5ad2f2a9c3e.bpFdUZ6dFKKinvbM5jklQHy3pQoeURgjrWtjcXipKBwscenes-app-insights-sqllinechart--sql-bar-chart-value-labels-quill--light:diff --git a/packages/quill/packages/charts/src/charts/BoxPlot/BoxPlot.tsx b/packages/quill/packages/charts/src/charts/BoxPlot/BoxPlot.tsxindex 58605f9e9114..c757915a8bc2 100644--- a/packages/quill/packages/charts/src/charts/BoxPlot/BoxPlot.tsx+++ b/packages/quill/packages/charts/src/charts/BoxPlot/BoxPlot.tsx@@ -65,8 +65,10 @@ export interface BoxPlotConfig extends ChartConfig {meanRadius?: number/** Whisker cap width as a fraction of the box width. Defaults to 0.6. */whiskerCapRatio?: number- /** Box outline / whisker stroke width. Defaults to 1.5. */+ /** Box outline / whisker stroke width. The median is three times as thick. Defaults to 1. */boxStrokeWidth?: number+ /** Box corner radius in CSS pixels. Defaults to 3; 0 draws square corners. */+ boxCornerRadius?: number}export interface BoxPlotClickData<Meta = unknown> {@@ -129,7 +131,8 @@ function BoxPlotInner<Meta = unknown>({showAxisLines = false,meanRadius = 3,whiskerCapRatio = 0.6,- boxStrokeWidth = 1.5,+ boxStrokeWidth = 1,+ boxCornerRadius,axisOrientation = 'vertical',} = config ?? {}const horizontal = axisOrientation === 'horizontal'@@ -281,12 +284,14 @@ function BoxPlotInner<Meta = unknown>({})drawBoxes(ctx, boxes, {color: s.color,- fillColor: dimColor(s.color, 0.25),- meanFillColor: dimColor(s.color, 0.5),+ fillColor: dimColor(s.color, 0.2),+ whiskerColor: theme.axisColor ?? s.color,+ meanFillColor: theme.backgroundColor ?? dimColor(s.color, 0.5),meanRadius,whiskerCapRatio,lineWidth: boxStrokeWidth,horizontal,+ cornerRadius: boxCornerRadius,})}@@ -298,7 +303,7 @@ function BoxPlotInner<Meta = unknown>({})}},- [showGrid, axisLines, meanRadius, whiskerCapRatio, boxStrokeWidth, axisOrientation, horizontal]+ [showGrid, axisLines, meanRadius, whiskerCapRatio, boxStrokeWidth, boxCornerRadius, axisOrientation, horizontal])const drawHover = useCallback(@@ -352,12 +357,12 @@ function BoxPlotInner<Meta = unknown>({if (!box) {continue}- drawBoxHighlight(ctx, box, dimColor(s.color, 0.25), horizontal)+ drawBoxHighlight(ctx, box, dimColor(s.color, 0.25), horizontal, boxCornerRadius)drewAny = true}return drewAny},- [series, horizontal]+ [series, horizontal, boxCornerRadius])const renderTooltip = useCallback(diff --git a/packages/quill/packages/charts/src/core/canvas-renderer.ts b/packages/quill/packages/charts/src/core/canvas-renderer.tsindex 4db3c2011ae9..1144474298f5 100644--- a/packages/quill/packages/charts/src/core/canvas-renderer.ts+++ b/packages/quill/packages/charts/src/core/canvas-renderer.ts@@ -1313,10 +1313,14 @@ export interface DrawBoxOptions {color: string/** Box fill — typically the series color at reduced alpha. */fillColor: string+ /** Whisker stem and cap color. Defaults to `color`. */+ whiskerColor?: string/** Optional explicit median stroke color. Defaults to `color`. */medianColor?: string/** Optional mean marker fill. Defaults to `fillColor`. */meanFillColor?: string+ /** Box corner radius in CSS pixels, clamped to half the box size. Defaults to 3. */+ cornerRadius?: number/** Mean marker radius in CSS pixels. Defaults to 3. */meanRadius?: number/** Line width for the box outline, whiskers, and median. Defaults to 1.5. */@@ -1334,10 +1338,12 @@ function transposeAxes(ctx: CanvasRenderingContext2D): void {ctx.transform(0, 1, 1, 0, 0, 0)}-/** Paint a whole series of box-and-whiskers, batching path operations so the number of- * `beginPath`/`stroke` pairs is `4 + N` instead of `5N` (whisker stems, caps, box outlines,- * and medians are each one shared path; mean markers stay per-box since each needs both- * fill and stroke). Pure: takes pre-laid-out {@link BoxRect}s; no scale access. */+const ALL_CORNERS: BarRoundedCorners = { topLeft: true, topRight: true, bottomLeft: true, bottomRight: true }+const DEFAULT_BOX_CORNER_RADIUS = 3++/** Paint a whole series of box-and-whiskers. Whisker stems, caps, and medians are each one+ * shared path; boxes and mean markers stay per-box since each needs its own fill and stroke.+ * Pure: takes pre-laid-out {@link BoxRect}s; no scale access. */export function drawBoxes(ctx: CanvasRenderingContext2D, boxes: BoxRect[], options: DrawBoxOptions): void {if (boxes.length === 0) {return@@ -1345,12 +1351,14 @@ export function drawBoxes(ctx: CanvasRenderingContext2D, boxes: BoxRect[], optioconst {color,fillColor,+ whiskerColor = color,medianColor = color,meanFillColor = fillColor,meanRadius = 3,lineWidth = 1.5,whiskerCapRatio = 0.6,horizontal = false,+ cornerRadius = DEFAULT_BOX_CORNER_RADIUS,} = optionsctx.save()@@ -1358,7 +1366,7 @@ export function drawBoxes(ctx: CanvasRenderingContext2D, boxes: BoxRect[], optiotransposeAxes(ctx)}ctx.lineWidth = lineWidth- ctx.strokeStyle = color+ ctx.strokeStyle = whiskerColorctx.setLineDash([])// 1. Whisker stems — only emit a stem when the whisker extends past the box edge.@@ -1394,19 +1402,23 @@ export function drawBoxes(ctx: CanvasRenderingContext2D, boxes: BoxRect[], optio}ctx.stroke()- // 3. Box rectangles (p25 → p75) — fill then outline. `fillRect` / `strokeRect` are- // already optimal — no `beginPath` accumulation needed.+ // 3. Rounded boxes (p25 → p75) — fill then outline. Each box is its own rounded path.ctx.fillStyle = fillColor+ ctx.strokeStyle = colorfor (const box of boxes) {const boxHeight = Math.max(0, box.bottom - box.top)- if (boxHeight > 0 && box.width > 0) {- ctx.fillRect(box.x, box.top, box.width, boxHeight)- ctx.strokeRect(box.x, box.top, box.width, boxHeight)+ if (boxHeight <= 0 || box.width <= 0) {+ continue}+ ctx.beginPath()+ traceRoundedBarPath(ctx, box.x, box.top, box.width, boxHeight, cornerRadius, ALL_CORNERS)+ ctx.fill()+ ctx.stroke()}- // 4. Median lines.+ // 4. Median lines — thicker than the outline so the median stands out.ctx.strokeStyle = medianColor+ ctx.lineWidth = lineWidth * 3ctx.beginPath()for (const box of boxes) {const medianClamped = Math.max(box.top, Math.min(box.bottom, box.medianY))@@ -1414,6 +1426,7 @@ export function drawBoxes(ctx: CanvasRenderingContext2D, boxes: BoxRect[], optioctx.lineTo(box.x + box.width, medianClamped)}ctx.stroke()+ ctx.lineWidth = lineWidth// 5. Mean markers — filled circle outlined in the series color. Stays per-box because// each marker requires both a fill and a stroke pass.@@ -1434,7 +1447,8 @@ export function drawBoxHighlight(ctx: CanvasRenderingContext2D,box: BoxRect,overlayColor: string,- horizontal = false+ horizontal = false,+ cornerRadius = DEFAULT_BOX_CORNER_RADIUS): void {const boxHeight = Math.max(0, box.bottom - box.top)if (box.width <= 0 || boxHeight <= 0) {@@ -1445,7 +1459,9 @@ export function drawBoxHighlight(transposeAxes(ctx)}ctx.fillStyle = overlayColor- ctx.fillRect(box.x, box.top, box.width, boxHeight)+ ctx.beginPath()+ traceRoundedBarPath(ctx, box.x, box.top, box.width, boxHeight, cornerRadius, ALL_CORNERS)+ ctx.fill()ctx.restore()}diff --git a/packages/quill/packages/charts/src/docs/chart-types.md b/packages/quill/packages/charts/src/docs/chart-types.mdindex 79c3fce2d3d2..5d2226379543 100644--- a/packages/quill/packages/charts/src/docs/chart-types.md+++ b/packages/quill/packages/charts/src/docs/chart-types.md@@ -99,6 +99,7 @@ Distribution summaries: `{ min, p25, median, mean, p75, max }` per label.Supports `config.legend` for grouped series and `onBoxClick`.`axisOrientation: 'horizontal'` lists the labels down the y-axis and draws values along x; `yScaleType: 'log'` then applies to that x value axis, and `yTickFormatter` formats its ticks.The tooltip receives a `BoxPlotTooltipContext`; `BoxPlotTooltip` is the default.+Boxes have a light tint of the series color, a thick median line, and whiskers in the axis color. Set `config.boxCornerRadius: 0` for square corners.## Heatmap