Add dual y-axis (y2) for line, area, bar, and combo charts - #63
Conversation
A y-column plots against an optional right-hand axis when listed in y2.field; all other series stay on the left y axis. y2 is a full axis encoding (title/format/beginAtZero/curve/dash), and ticks and tooltip values format per axis. Validated on line/area/bar/combo, number type, disjoint from y, and not combined with stacked/horizontal/color.
Prompt To Fix All With AI### Issue 1
frontend/src/components/widgets/ChartWidget.tsx:1179
**Reference guides lose their axis**
When a line, area, or bar chart combines `y2` with a y-oriented reference line or band, the axes are renamed `left` and `right` while the reference retains the default axis ID, causing the configured guide to disappear.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "Add dual y-axis (y2) for line, area, bar..." | Re-trigger Greptile |
| ? { label: { value: widget.y2.title, angle: 90, position: "insideRight" as const, style: { ...AXIS_STYLE, fill: axisColor } } } | ||
| : {})} | ||
| /> | ||
| ) : null; |
There was a problem hiding this comment.
Reference guides lose their axis
When a line, area, or bar chart combines y2 with a y-oriented reference line or band, the axes are renamed left and right while the reference retains the default axis ID, causing the configured guide to disappear.
Prompt To Fix With AI
This is a comment left during a code review.
Path: frontend/src/components/widgets/ChartWidget.tsx
Line: 1179
Comment:
**Reference guides lose their axis**
When a line, area, or bar chart combines `y2` with a y-oriented reference line or band, the axes are renamed `left` and `right` while the reference retains the default axis ID, causing the configured guide to disappear.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.There was a problem hiding this comment.
Fixed in 6e3f614 — renderRefs now takes a yAxisId and the line/area/bar cases pass leftAxisId, so refLines/refBands bind to the left axis when y2 is present (undefined and unchanged otherwise). Note combo is excluded since the validator already restricts refLines/refBands to line/area/bar/forest. Verified: a y-axis Target ref line now renders on a dual-axis line chart.
|
Reviews (2): Last reviewed commit: "gofmt: align widget struct tags" | Re-trigger Greptile |
renderRefs now takes a yAxisId so refLines/refBands resolve to an existing axis when y2 is present; without y2 the id is undefined and behaviour is unchanged.
|
Reviews (3): Last reviewed commit: "Bind reference lines/bands to the left a..." | Re-trigger Greptile |
Adds an optional second value axis (
y2) on the right side of cartesian charts. A y-column plots against the right axis when listed iny2.field; all other series stay on the leftyaxis. This lets two series on different scales (e.g. revenue in$and conversion rate in%) share one chart without the smaller-scale series being squashed flat.y2is a full axis encoding — sametitle,format,beginAtZero,curve,dashasy.y.format, right usesy2.format).line,area,bar, andcombo. Axis assignment (yvsy2) is independent of shape (bar vs line vialines).y2.typemust benumber, columns are disjoint fromy, andy2is rejected withstacked,horizontalbars, orcolor.testdata/dashboards/charts.ymlcombo now usesy2.Example
```yaml
chart: combo
lines: [conversion_rate]
y: { field: [revenue], title: Revenue, format: "$,.0f" }
y2: { field: [conversion_rate], title: Conversion, format: ".1%" }
```