This is a migrated thread and some comments may be shown as answers.

RadCartesianChart tooltip template

5 Answers 160 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Tinja
Top achievements
Rank 1
Tinja asked on 18 Sep 2013, 01:51 PM
Hi!
I have tried to create a custom template for a tooltip and I've implemented a simple template with custom context. However I realized that the tooltip displays only one series' values in the ClosestDataPoint. While debugging this I noticed that all the DataPointInfos had the same DistanceToTouchLocation, and I assume this is the reason why the ClosestDataPoint's series is always the same.

I was wondering if there's a solution for this.

- Tinja

In the ChartTooltipBehavior I've defined the TriggerMode to be Hold and SnapToClosestPoint is set to true.
Here's my implementation of the template and the ContextNeeded event handler:
        <telerikChart:RadCartesianChart.TooltipTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
 <RowDefinition/>
 <RowDefinition/>
</Grid.RowDefinitions>
<TextBlock Text="{Binding Path=Header}"/>
<TextBlock Text="{Binding Path=Content}" Grid.Row="1"/>
</Grid>
</DataTemplate>
</telerikChart:RadCartesianChart.TooltipTemplate>

private
void ChartTooltipBehavior_ContextNeeded(object sender, TooltipContextNeededEventArgs e)
        {
 
            e.Context = new CustomTooltipContext()
                            {
                                Header = e.DefaultContext.ClosestDataPoint.Series.DisplayName,
                                Content = e.DefaultContext.ClosestDataPoint.DisplayContent.ToString()
                            };
        }

5 Answers, 1 is accepted

Sort by
0
Rosy Topchiyska
Telerik team
answered on 23 Sep 2013, 11:41 AM
Hi Tinja,

Thank you for your question.

The distance to the data point is calculated as the horizontal distance between the point and the touch location. This is why all closest points from the series have the same DistanceToTouchLocation
and ClosestDataPoint is always from the first series. Each DataPoint in the DefaultContext.DataPointInfos has LayoutSlot property that provides information about the position of the data point. Using this information, you can calculate which one is the nearest point.

I hope this was useful and, please, let us know if you have further questions.

Regards,
Rositsa Topchiyska
Telerik
Have a suggestion or face a problem - you can use the Ideas & Feedback portal to submit ideas, feedback and vote for them.
0
David Renza
Top achievements
Rank 1
answered on 10 Oct 2013, 06:23 AM
Hi,

in version for WPF (version 2013.2.724.45) is same behavior described by Tinja, but no LayoutSlot property is available. Is there a way how to find really closest data point in WPF? Thanks.

David
0
Tina Stancheva
Telerik team
answered on 15 Oct 2013, 11:06 AM
Hello David,

Unfortunately the charting components for WPF and Windows8 are different and their implementation is build around the specifics of each of the frameworks. This is why it would be better to further describe your scenario and current implementation in a ticket or a forum thread targeting RadChart(View) for WPF.

Also, please note that in WPF we provide two different charting components - RadChart and RadChartView. The RadChartView is the latest implementation of our charting components and its advantages are further described in this article.

Having the above in mind, please create a ticket/forum thread targeting the charting component you're currently using and describe your scenario and the implementation you have in place. As in WPF we don't have a ContextNeeded event and a LayoutSlot property, your description will help us better understand your requirements and advice you how to implement them.

Regards,
Tina Stancheva
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Sumit
Top achievements
Rank 1
answered on 08 Jul 2015, 11:11 AM
  Your All Suggestions And Link Are Bad.........
0
Martin Ivanov
Telerik team
answered on 10 Jul 2015, 07:23 AM
Hello Sumit,

Can you please tell us why do you think that the suggestions and link are not okay? If you point out the things that concerns you we might be able to give you additional information on the matter.

Regards,
Martin
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Chart
Asked by
Tinja
Top achievements
Rank 1
Answers by
Rosy Topchiyska
Telerik team
David Renza
Top achievements
Rank 1
Tina Stancheva
Telerik team
Sumit
Top achievements
Rank 1
Martin Ivanov
Telerik team
Share this question
or