Skip to content

Issue #679: standardize custom tooltips via ToolTipGenerator on all series types - #1022

Merged
timmolter merged 1 commit into
developfrom
issue-679-tooltip-generator
Jul 31, 2026
Merged

Issue #679: standardize custom tooltips via ToolTipGenerator on all series types#1022
timmolter merged 1 commit into
developfrom
issue-679-tooltip-generator

Conversation

@timmolter

Copy link
Copy Markdown
Member

Closes #679

What

Adds one standardized way to customize tooltip text on every chart type, replacing the ad-hoc per-chart-type approaches:

chart.getHeatMapSeries().setToolTipGenerator(
    dataPoint -> dataPoint.getLabel()
        + System.lineSeparator()
        + extraInfo[dataPoint.getDataPointIndex()]);
  • New ToolTipGenerator functional interface (ChartDataPoint -> String), settable on the base Series class via a fluent setToolTipGenerator(...), so it works on XY, Category, Bubble, HeatMap, Box, OHLC, Radar, Pie, Dial, and HorizontalBar charts alike.
  • The generator receives the series name, the data point's index within the series data (for looking up raw values / extra info in application data structures), the default formatted label, and screen geometry. Returning null falls back to the default label.
  • Multi-line tooltips are supported: any label containing System.lineSeparator() is now painted multi-line (previously hardcoded to Box/OHLC stylers only — resolves an old TODO in ToolTips).

How

The generator is applied in exactly one place — ToolTipData.withSeries(series, index) in PlotInteractionData — so each PlotContent_* class only attaches series identity to its tooltips. That attachment already existed for XY, Category, Bubble, and HorizontalBar; this PR adds it to HeatMap, Box, OHLC, Radar, Pie, and Dial, which as a side benefit extends DataPointListener (#492) series/index reporting to those six chart types too. DataPointDispatcher reports the displayed (custom) label to listeners.

Deprecations (removal in 4.1.0)

Both continue to work; a ToolTipGenerator takes precedence when both are set (documented and tested).

Tests / demo

  • ToolTipGeneratorTest: six headless tests (no XChartPanel) covering label replacement, null-fallback, series identity/index correctness, the HeatMap case from the issue, and bubble precedence/backward compatibility.
  • TestForIssue679 demo: HeatMap whose tooltips append per-cell application data, with tooltips enabled on the panel.

Full mvn test passes across all modules.

🤖 Generated with Claude Code

…eries

Adds a ToolTipGenerator functional interface (ChartDataPoint -> String)
settable on any series, applied centrally in ToolTipData.withSeries().
Attaches series identity in the six PlotContent classes that lacked it,
paints multi-line labels as multi-line everywhere, and deprecates the
per-point String[] tooltip APIs on BubbleSeries and RadarSeries.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@timmolter
timmolter merged commit 04b26c5 into develop Jul 31, 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.

Question: is their any way to provide our own custom tool tips for HeatMap?

1 participant