SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and iOS Chart & Android Chart Components

1
0

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

  1. Appear on left-click rather than on hover
  2. Stay open until the user clicks outside them (or the mouse leaves the chart area)
  3. 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.

Version
5.2.0.11680
  • David La Fleur
    Upon further thought, maybe it makes more sense to do this with a custom annotation?
  • You must to post comments
0
0

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:

  1. Creating a custom modifier from scratch, e.g. see Custom ChartModifiers – Part 1 – Creating a Custom Rollover Modifier
  2. Or two, yes trying other techniques such as annotations

There is a sandbox application with custom modifier examples over at github.

Best regards,
Andrew

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.