chartview tooltip event

7 posts, 0 answers
  1. Marcel
    Marcel avatar
    25 posts
    Member since:
    Jan 2011

    Posted 07 May 2013 Link to this post

    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>
  2. Heath Morris
    Heath Morris avatar
    4 posts
    Member since:
    Sep 2009

    Posted 09 May 2013 Link to this post

    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.
  3. DevCraft banner
  4. Marcel
    Marcel avatar
    25 posts
    Member since:
    Jan 2011

    Posted 09 May 2013 Link to this post

    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.
  5. Jorn
    Jorn avatar
    222 posts
    Member since:
    Jun 2009

    Posted 10 May 2013 Link to this post

    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)
  6. Petar Kirov
    Admin
    Petar Kirov avatar
    425 posts

    Posted 10 May 2013 Link to this post

    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.

  7. Marcel
    Marcel avatar
    25 posts
    Member since:
    Jan 2011

    Posted 30 May 2013 Link to this post

    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.
  8. Petar Kirov
    Admin
    Petar Kirov avatar
    425 posts

    Posted 04 Jun 2013 Link to this post

    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.

Back to Top
DevCraft banner