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

chartview tooltip event

6 Answers 92 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Marcel
Top achievements
Rank 1
Marcel asked on 07 May 2013, 05:06 PM
Hello,

I have a tooltip defined on a RadCartesianChart (ChartView). When I hover over a data point in the chart, I need to a) show the tootip (done) and b) populate the tooltip - which is actually a RadGridView. 
1) Is there an event I can intercept to detect when I am hovering over the data point, so that I can bind my grid? I need to know which data point I am hovering over.  It is not practical to prebind the tooltip details for every data point (as shown below).
2) My grid is not resolving in the code-behind - what do I need to do to gain addressability to it?

Thank you
<telerik:RadCartesianChart.Behaviors >
    <telerik:ChartTooltipBehavior Placement="Top" VerticalOffset="0" HorizontalOffset="-10" />
</telerik:RadCartesianChart.Behaviors >
<telerik:RadCartesianChart.TooltipTemplate>
    <DataTemplate>
        <Grid>
            <StackPanel Margin="5,5,5,18">
             <telerik:RadGridView Name="DatabaseDetailRadGridView" 
                        Height="250" 
                        AutoGenerateColumns="False" 
                        ItemsSource="{Binding DataItem.Details}">
                    <telerik:RadGridView.Columns>
                        <telerik:GridViewDataColumn Header="Database" IsGroupable="False" IsFilterable="False" IsResizable="False" IsReorderable="False" ShowFilterButton="False" ShowFieldFilters="False" ShowDistinctFilters="False" ShowColumnWhenGrouped="False" />
                    </telerik:RadGridView.Columns>
                </telerik:RadGridView>

6 Answers, 1 is accepted

Sort by
0
Heath Morris
Top achievements
Rank 2
answered on 09 May 2013, 06:57 PM
It would be helpful to know what type of Series you are using. For a LineSeries, if you do not have some kind of visual on the datapoint you will not get a tooltip. if you don't want a visual just add a transparent rectangle or ellipse, I can provide an example if you need. Otherwise your binding looks fine. I am just wondering if you can even see the tootip if it is something simple like a rectangle etc.
0
Marcel
Top achievements
Rank 1
answered on 09 May 2013, 08:33 PM
Hi Heath,
Thank you for your interest. I am using BarSeries for some and LineSeries for some. The tooltips work but I am retrieving all of the tootip details up front for all data points. There may be many data points and the tooltip data iteslf may be a lot for each data point. Ideally I would like to get the tootip data only for the data point I am hovering over - on demand.
0
Trude
Top achievements
Rank 2
answered on 10 May 2013, 11:42 AM
For both 1 and 2:

The RadGridView should listen to the DataContextChanged event. In the event handler you can find the needed references (including the datapoint, the radgrid and the grid)
0
Petar Kirov
Telerik team
answered on 10 May 2013, 03:42 PM
Hi Marcel,

You can use a converter in the GridView ItemsSource binding. In the IValueConverter.Convert method you can apply your custom logic for retrieving the GridView data, given the data point for which the tooltip is displayed. I have attached a sample project demonstrating this.

I hope this helps.
 

Regards,
Petar Kirov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Marcel
Top achievements
Rank 1
answered on 30 May 2013, 04:38 PM
Hi Petar,
Thank you very much for your example. I have one remaining question more related to silverlight than Telerik.

I am getting my tooltip data using a WCF async call. Apparently Silverlight does not support synchronous calls on the UI thread. The IValueConverter requires a synchronous return.

I imagine I could use a sleep loop in the converter which is released when the async call is completed.
Do you have a pattern or alternative approach when using aysnchronous data?

Thank you again for any help.
0
Petar Kirov
Telerik team
answered on 04 Jun 2013, 10:17 PM
Hi Marcel,

Instead of waiting in the Convert method of the IValueConverter for the data to come from the service, you can trigger an async method in your ViewModel. After triggering it your UI will become responsive and when the data arrives the execution will pick off from where it left in the method. The method will update the GridView ItemsSource property of the ViewModel and the GridView will update its content.

I have attached a sample project which uses a WCF service to load RSS feeds and visualizes them using the UI from the previously attached project. Please note that I have used the async feature of C#5, so I had to set the TargetFramework version to 4.5. Additionally, for the Silverlight project I had to reference the Async Targeting Pack NuGet package. For more information on this you can check this blog post.

I hope this was helpful! 

Regards,
Petar Kirov
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
ChartView
Asked by
Marcel
Top achievements
Rank 1
Answers by
Heath Morris
Top achievements
Rank 2
Marcel
Top achievements
Rank 1
Trude
Top achievements
Rank 2
Petar Kirov
Telerik team
Share this question
or