Hi all. I would like to add tooltips to my chart, but have them behave a bit differently than they do by default. Specifically, they should
- Appear on left-click rather than on hover
- Stay open until the user clicks outside them (or the mouse leaves the chart area)
- Not appear if another ToolTip is already open (mostly follows from #2)
The existing ToolTipModifier can give me #1, but not #2 or #3, as far as I can tell.
So what’s the best way for me to implement this behavior? Can I get to it by subclassing the existing ToolTipModifier, or do I need to start from scratch? And if deriving is the answer, what would I need to override?
My motivation is that I would like to place buttons/hyperlinks in the tooltip for performing actions related to the clicked datapoint, so if there are completely different ways to achieve this that don’t involve tooltips at all, I’m open to suggestions.
- David La Fleur asked 6 years ago
-
Upon further thought, maybe it makes more sense to do this with a custom annotation?
- You must login to post comments
I think this might require a code-change to achieve, or a totally custom modifier.
The RolloverModifier.HandleMasterMouseEvent method has this code:
protected override void HandleMasterMouseEvent(Point mousePoint)
{
if (ShowTooltipOn == ShowTooltipOptions.MouseHover && PointUtil.Distance(mousePoint, _lastMouseMovePoint) >= HOVER_EPSILON)
{
ClearTooltipLabels();
_lastMouseMovePoint = mousePoint;
}
// ...
}
This is where we decide when to show the tooltip depending on ShowTooltipOn option.
To modify that you’d need to a.) have access to our source code and b.) inherit the RolloverModifier and change that behaviour of when tooltips are shown.
Other alternatives include:
- Creating a custom modifier from scratch, e.g. see Custom ChartModifiers – Part 1 – Creating a Custom Rollover Modifier
- Or two, yes trying other techniques such as annotations
There is a sandbox application with custom modifier examples over at github.
Best regards,
Andrew
- Andrew Burnett-Thompson answered 6 years ago
- You must login to post comments
Please login first to submit.