SnapMode=ClosestPoint on ScatterPointSeries shows multiple points

1 Answer 13 Views
Chart
Neil
Top achievements
Rank 1
Neil asked on 09 May 2021, 07:37 PM

Hi,

I have a scatter point series with chart track ball enabled and SnapMode set to ClosestPoint, but with multiple series added to the chart I see a point per series.

 

Each colour in above image is a separate series added from code. The chart itself is in XAML.


                    <telerik:RadCartesianChart Grid.Row="0"   BorderBrush="Transparent" Background="White"  x:Name="radChartView" HorizontalAlignment="Stretch" VerticalContentAlignment="Stretch" DockPanel.Dock="Top">
                        <telerik:RadCartesianChart.Behaviors>
                            <telerik:ChartTrackBallBehavior ShowIntersectionPoints="True" ShowTrackInfo="False" SnapMode="ClosestPoint" />
                        </telerik:RadCartesianChart.Behaviors>
                        <telerik:RadCartesianChart.TrackBallLineStyle>
                            <Style TargetType="Polyline">
                                <Setter Property="Visibility" Value="Collapsed" />
                            </Style>
                        </telerik:RadCartesianChart.TrackBallLineStyle>

                    </telerik:RadCartesianChart>

 

I've only seen examples of SnapMode=ClosestPoint on LineSeries plots. Should this work on ScatterPointSeries?

Thanks,

Neil

1 Answer, 1 is accepted

Sort by
0
Dinko
Telerik team
answered on 12 May 2021, 11:17 AM

Hello Neil,

Thank you for the provided code snippet.

Our RadChartView TrackBall behavior supports ScatterSeries. Looking at the code snippet, the ShowTrackInfo property of the ChartTrackBallBehavior is set to false. This way, you are going to see only the intersection points. Is this behavior intended? Can you share if you want to achieve something different with our trackball functionality of the RadChartView?

Regards,
Dinko
Progress Telerik

Тhe web is about to get a bit better! 

The Progress Hack-For-Good Challenge has started. Learn how to enter and make the web a worthier place: https://progress-worthyweb.devpost.com.

Neil
Top achievements
Rank 1
commented on 12 May 2021, 11:22 AM

Hi Dinko,

With SnapMode=ClosestPoint I'm expecting to only see one point highlighted on the whole chart, rather than one point per series.

Similarly when I enable the tooltip I'm expecting to see a single point's data, rather than a point per series.

Thanks,

Neil
Dinko
Telerik team
commented on 14 May 2021, 07:16 AM

Hi Neil,

By default, the SnapMode functionality of the TrackBall will show the closes data points per series. To show only one point which is the closes one, you can subscribe to the TrackInfoUpdated event of the ChartTrackBallBehavior. In the event handler, you can get all closes points from the e.Context.DataPointInfos collection and the closes point from e.Context.ClosestDataPoint property. Using this you can only leave the ClosestDataPoint inside the collection. The following code demonstrates what I have in mind.

private void ChartTrackBallBehavior_TrackInfoUpdated(object sender, TrackBallInfoEventArgs e)
{
    var dataPointInfos = e.Context.DataPointInfos.ToList();
    foreach (DataPointInfo dataPointInfo in dataPointInfos)
    {
        if(dataPointInfo != e.Context.ClosestDataPoint)
        {
            e.Context.DataPointInfos.Remove(dataPointInfo);
        }
    }
}
Neil
Top achievements
Rank 1
commented on 19 May 2021, 08:19 PM

Thanks Dinko - that's exactly what I was after.
Tags
Chart
Asked by
Neil
Top achievements
Rank 1
Answers by
Dinko
Telerik team
Share this question
or