Skip to content

Fix #686: truncate long legend series names with ellipsis#945

Merged
timmolter merged 1 commit into
developfrom
timmolter/fix-686-legend-long-series-name
May 25, 2026
Merged

Fix #686: truncate long legend series names with ellipsis#945
timmolter merged 1 commit into
developfrom
timmolter/fix-686-legend-long-series-name

Conversation

@timmolter
Copy link
Copy Markdown
Member

Problem

When a series name is very long, the legend width grows to exceed the chart width, pushing the plot area to zero (or negative) width. The chart content disappears entirely — both in the Swing display and in exported bitmaps.

Fix

In Legend_.java, getSeriesTextBounds() now computes a max text width of 45% of the chart width. If a label line exceeds that, a new truncateLabel() helper trims characters from the right and appends until it fits.

Demo

TestForIssue686.java in standalone/issues/ shows a series with a very long name rendered correctly with a truncated legend entry.

Fixes #686

A series name longer than 45% of the chart width caused the legend to
overflow, leaving no room for the plot area. getSeriesTextBounds() now
caps each line at MAX_LEGEND_TEXT_WIDTH_RATIO (0.45) of the chart width
and appends "…" when truncation is needed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@timmolter timmolter merged commit c84acb8 into develop May 25, 2026
1 check 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.

An issue with larger series name

1 participant