Skip to content

geom: a called-out label is broken or shrunk before it is dropped - #51

Merged
timzifer merged 1 commit into
mainfrom
callout-wrap-and-shrink
Sep 22, 2026
Merged

timzifer merged 1 commit into
mainfrom
callout-wrap-and-shrink

Conversation

@timzifer

Copy link
Copy Markdown
Owner

Why

A label called out of a thin slice at nine or three o'clock has only the margin beside the chart. In a sunburst whose panel is not much wider than the ring, the long names were dropped there — the ones a reader cannot guess from the colour, and the ones a callout exists for.

What

A called-out label is fitted to the room on its own side the way a box label is fitted to its box, in the same order:

  1. one line at the layer's size (unchanged),
  2. broken over two or three lines where Wrap allows it,
  3. shrunk down to MinFontSize, on whichever shape holds the largest type,
  4. only then dropped with its leader.

The shape is settled before stacking; labels on one side are stacked apart by half of each neighbour's height plus a pixel (for one-line labels: the same step as before). The leader meets a wrapped block in its middle.

Labels that fitted before are unchanged — golden files and the gallery are the same.

  • geom/text.go: calloutShape, per-callout font/shape/block, height-aware stacking
  • geom/textfit_test.go: wrapped instead of dropped, shrunk without Wrap (dropped with MinFontSize at the layer's size), stacked by block height
  • ADR 0082: amendment; Callout / Wrap docs

Tests

go test ./..., backend/gg incl. gallery (via go.work), go vet ./...

🤖 Generated with Claude Code

A label called out of a thin slice at nine or three o'clock has only the
margin beside the chart, and the long names were dropped there - the ones
a callout exists for. A called-out label is now fitted to the room on its
own side the way a box label is fitted to its box: one line at the
layer's size, then broken over two or three lines where Wrap allows it,
then shrunk down to MinFontSize, and only then dropped.

The shape is settled before stacking, and labels on one side are stacked
apart by half of each neighbour's height, so a block takes as many lines
of the column as it has. Labels that fitted before are unchanged; the
golden files and documentation figures are the same.

See the amendment to ADR 0082.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@timzifer
timzifer merged commit ff1a3e0 into main Sep 22, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant