Skip to content

feat: add tooltip support#721

Draft
80avin wants to merge 1 commit intoplotters-rs:masterfrom
80avin:master
Draft

feat: add tooltip support#721
80avin wants to merge 1 commit intoplotters-rs:masterfrom
80avin:master

Conversation

@80avin
Copy link

@80avin 80avin commented Feb 11, 2026

fixes #13
It works, but I don't like the presence of

  • DrawingBackend::with_tooltips function
    tooltip should be enabled per chart, not backend.
  • draw_series_with_tooltips api.
    Ideally, it should work with draw_series API and tooltip should be a configuration parameter.

Challenge:

  • The library gives user the control over when to draw. Because of this, we don't have enough information in draw_series to emit the tooltips code.

Alternative API:

  • chart.tooltip_mode(TooltipMode) shall enable tooltips for current chart.
    mode can be "Auto", "Always", "Disable". If Always and the backend doesn't support, there should be error.
  • On every draw ( and .label, etc) call, keep on building internal state.
    Also, SVG backend shall add classes wherever required to uniquely identify elements, if tooltip mode is enabled.
  • On present call, add javascript to enable tooltips.

Question to the maintainers:

  • Does the API feel satisfactory, or do you have better suggestions?
image

AI use:
The initial approach, including the API was designed after manual experiments. AI is used to scale the approach into a wider & cleaner solution.

@philocalyst
Copy link

philocalyst commented Mar 17, 2026

Still working on this? @80avin

@80avin
Copy link
Author

80avin commented Mar 17, 2026

Waiting for opinions on the architecture.
The PR works for most cases already.

@philocalyst
Copy link

philocalyst commented Mar 17, 2026 via email

@80avin
Copy link
Author

80avin commented Mar 18, 2026

Thanks Miles.
I added the note about AI usage in the PR description.

Also, phrased a clearer question to maintainers in the PR description. Completing the PR is not an issue, but I am myself unconvinced by the current API. I went with this API design while trying to keep the breaking changes to a minimum; otherwise, the backend system would have needed major breaking changes

@philocalyst
Copy link

philocalyst commented Mar 18, 2026 via email

@80avin
Copy link
Author

80avin commented Mar 20, 2026

I've tried to explain that in the PR description. If something is difficult to understand, I can take specific questions.

In abstract terms, breaking changes like

  • Changing what data is shared with backends.
    Currently, backends only get low level information of what figure to draw and where. But, for a backend to draw tooltips or other decorations, it needs to have some semantic information about the chart.
    The begin_context/end_context that I added work but are after-thoughts, designed to add tooltip support without changing much in existing design.
  • Changing the user facing API.
    As I mentioned in the PR description, the backend.with_tooltip is not ideal. Ideally, we would want to enable/disable tooltip per chart ( or element of chart ) than entire backend.

Let me know your thoughts on these, or if I'm thinking too much. If the current design looks good, I can finish the PR and move out of draft.

@philocalyst
Copy link

philocalyst commented Mar 20, 2026 via email

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.

[feature request] Interactivity

2 participants