Skip to content

demo: Strings on the Y-axis via custom tick formatter (issue #884)#979

Merged
timmolter merged 1 commit into
developfrom
issue-884-yaxis-strings-demo
Jun 22, 2026
Merged

demo: Strings on the Y-axis via custom tick formatter (issue #884)#979
timmolter merged 1 commit into
developfrom
issue-884-yaxis-strings-demo

Conversation

@timmolter

Copy link
Copy Markdown
Member

Closes #884.

Adds a runnable demo showing how to display String labels on the Y-axis of any axes-based chart, without a dedicated chart type or an axis-swap flag.

Approach

Plot rows as numeric category indices (0, 1, 2, …) and map each numeric Y tick back to its String via Styler#setYAxisTickLabelsFormattingFunction(Function<Double,String>). Non-integer grid positions return "" so no stray numeric labels appear.

Result

A scatter XYChart whose Y-axis reads Apples / Bananas / Cherries / Dates / Elderberries instead of 0–4, with the X-axis staying numeric. Verified by rendering to PNG headless.

Notes

  • Follows the existing standalone/issues/TestForIssueNNN convention with the getChart() / main() split so it's headless-safe.
  • For the bar-chart case specifically, HorizontalBarChart already supports String categories on Y natively (its yData is List<?>); this demo covers the general case.

🤖 Generated with Claude Code

Adds TestForIssue884 showing how to display String labels on the
Y-axis of any axes-based chart by plotting numeric category indices
and mapping them back to Strings with
setYAxisTickLabelsFormattingFunction.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@timmolter timmolter merged commit f8b104c into develop Jun 22, 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.

Categories in Y-Axis or Swap axes

1 participant