Skip to content

Commit fbd8855

Browse files
ryo-manbaclaude
andcommitted
fix: bottom legend spacing and layout calculation
- Fix bottom legend overlapping X-axis labels by adding padding to bottom of chart area (pb += 32) instead of only increasing SVG height - This keeps chart area size consistent while adding dedicated space below X-axis labels for the legend Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e89154e commit fbd8855

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/renderer/common.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ export function createSvg(w: number, h: number): SVGSVGElement {
2121

2222
export function computeLayout(c: ChartConfig, sc: number): ChartLayout {
2323
const w = 500,
24-
h = c.height + (c.legend === "bottom" && sc > 1 ? 28 : 0),
24+
legendBottom = c.legend === "bottom" && sc > 1,
25+
h = c.height + (legendBottom ? 32 : 0),
2526
pt = 20 + (c.legend === "top" && sc > 1 ? 28 : 0),
2627
pl = 46,
2728
pr = 20,
28-
pb = 36;
29+
pb = 36 + (legendBottom ? 32 : 0);
2930
return {
3031
width: w,
3132
height: h,
@@ -179,7 +180,7 @@ export function renderLegend(
179180
return;
180181
const g = svgEl("g", { class: P + "legend" }),
181182
tc = getThemeColor("text");
182-
const y = cfg.legend === "bottom" ? l.height - 8 : 16;
183+
const y = cfg.legend === "bottom" ? l.height - 4 : 16;
183184
let x = l.paddingLeft;
184185
for (let i = 0; i < data.headers.length; i++) {
185186
const h = data.headers[i] ?? "";

0 commit comments

Comments
 (0)