The issue I am running into is that when we hover over the plot, the tooltip does not represent the series that eventually becomes flagged as selected. This occurs when there are several line series grouped closely together.
I am using the default tooltip modifier together with a custom selection modifier.
I was wondering whether there is a way to obtain the tooltip information in our OnModifierMouseDown or somehow reconcile the hit testing of the tooltip modifier and our custom selection modifier (logic below). Our hit test radius is 9 because this seemed to be closest to the default tooltip hittest radius.
(Note our CustomSeriesSelectionModifier overrides ChartModifierBase. It does not override the default seriesselectionmodifier class because we found that it was not giving us adequate control over the selection rules)
Example scenario: Three curves grouped closely together. Hovering over them shows the tooltip for curve 3. Clicking selects curve 1 (even while the tooltip for curve 3 is still visible)
Thanks in advance
public class CustomSeriesSelectionModifier : ChartModifierBase
{
public CustomSeriesSelectionModifier()
: base()
{
ReceiveHandledEvents = true;
}
public override void OnModifierMouseDown( ModifierMouseArgs e )
{
base.OnModifierMouseDown( e );
var point = GetPointRelativeTo( e.MousePoint, ModifierSurface );
Vector smallestDifference = new Vector( double.MaxValue, double.MaxValue );
IRenderableSeries hitSeries = null;
foreach ( var series in this.ParentSurface.RenderableSeries )
{
var hitTest = series.HitTest( point, 9.0 );
if ( hitTest.IsHit )
{
Vector diff = Point.Subtract( point, hitTest.HitTestPoint );
if ( smallestDifference.Length > diff.Length )
{
smallestDifference = diff ;
hitSeries = series;
}
}
}
if ( hitSeries != null )
{
// do custom selection stuff
}
}
}
- John Chow asked 4 years ago
- last edited 4 years ago
- You must login to post comments
Please login first to submit.