Skip to content

Tooltip: new plot type#4829

Merged
swharden merged 11 commits intoScottPlot:mainfrom
CoderPM2011:feat/Tooltip
Mar 16, 2025
Merged

Tooltip: new plot type#4829
swharden merged 11 commits intoScottPlot:mainfrom
CoderPM2011:feat/Tooltip

Conversation

@CoderPM2011
Copy link
Contributor

@CoderPM2011 CoderPM2011 commented Feb 27, 2025

resolve #4751.

I inherited class of Text Plot and added the graphic rendering part of Tooltip.

Since RenderTooltipShape() is designed to be protected virtual, users can implement custom subclasses if they have different ideas about the current design. 😉


The current design requires the tail target coordinates to be specified and will automatically rotate in the target direction.

Customizable tooltip tail width percentage.
The actual width of the tail is the lesser of the length or width of the tooltip body.

The image below shows the actual shape of the tail profile.

image


demo image

image

demo code

Coordinates origin = new(0, 0);
for (int i = 360; i > 0; i -= 30)
{
    PolarCoordinates polar = new(i + 1, Angle.FromDegrees(i));
    var tooltip = formsPlot1.Plot.Add.Tooltip($"{i}", polar.ToCartesian(), origin);
    tooltip.Alignment = Alignment.MiddleCenter;
    tooltip.FillColor = Colors.Red.WithAlpha(0.5);
    tooltip.LineColor = Colors.Black.WithAlpha(0.5);
    tooltip.LineWidth = 5;
}

Copy link
Member

@bclehmann bclehmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, I just have a couple of thoughts but a lot of them are minor and nitpicky

@swharden
Copy link
Member

Hi @CoderPM2011, thanks so much for this PR! I'm going to put some time into this now and will refactor it a bit, merge, and publish a new package today 🚀

I suspect I'll disentangle the inheritance structure, and also address Ben's concern about text customization along the way

@swharden
Copy link
Member

Note that the "cutting" isn't pixel perfect, so I'll probably remove that feature...

image

image

@swharden
Copy link
Member

cookbook recipes

image

@swharden swharden enabled auto-merge (squash) March 16, 2025 19:13
@swharden swharden merged commit 6af2c6c into ScottPlot:main Mar 16, 2025
3 checks passed
@CoderPM2011 CoderPM2011 deleted the feat/Tooltip branch March 16, 2025 23:09
@swharden
Copy link
Member

publish a new package today

publish a new package today very soon 😅

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.

Tooltip: new plot type (copy from ScottPlot 4)

3 participants