trigger ChartTrackBallBehavior

5 posts, 0 answers
  1. Enrico
    Enrico avatar
    14 posts
    Member since:
    Mar 2011

    Posted 05 Jun 2012 Link to this post

    how can I trigger the ChartTrackBallBehavior programmatically?
    In my scenario I set the chart IsManipulationEnabled to True. Since this I don't get the TrackBallInfo when I touch the chart. Is there a way to get around this?

  2. Lancelot
    Lancelot avatar
    251 posts
    Member since:
    Jul 2012

    Posted 06 Jun 2012 Link to this post

    Hi Enrico,

    You can access the trackball from your code behind by adding a behavior to your chart. I have an example below for you. The first code block is the XAML. Notice how there is a ChartTrackBallBehavior property that inherits from a RadCartesianChart.Behaviors class. Inside the property there is an event named "TrackInfoUpdated".  The second code block below contains the event handler for that event, everytime the trackball moves it fires off that event.

          <Style TargetType="telerik:TrackBallInfoControl">
             <Setter Property="HeaderTemplate">
                      <TextBlock Text="{Binding}"
          <telerikChart:ChartTrackBallBehavior ShowTrackInfo="True"
          <telerikChartEngine:CategoricalDataPoint Value="0.2" />
          <telerikChartEngine:CategoricalDataPoint Value="0.4" />
          <telerikChartEngine:CategoricalDataPoint Value="0.5" />
          <telerikChartEngine:CategoricalDataPoint Value="1.4" />
          <telerikChartEngine:CategoricalDataPoint Value="1.0" />
          <telerikChartEngine:CategoricalDataPoint Value="1.3" />
          <telerikChartEngine:CategoricalDataPoint Value="0.1"/>
          <telerikChartEngine:CategoricalDataPoint Value="0.3"/>
          <telerikChartEngine:CategoricalDataPoint Value="0.3"/>
          <telerikChartEngine:CategoricalDataPoint Value="0.4"/>
          <telerikChartEngine:CategoricalDataPoint Value="0.2"/>
          <telerikChartEngine:CategoricalDataPoint Value="0.3"/>

    And now here is the c#  event handler...

    private void ChartTrackBallBehavior_TrackInfoUpdated(object sender, TrackBallInfoEventArgs e)
        foreach (DataPointInfo info in e.Context.DataPointInfos)
            info.DisplayHeader = "Custom data point header";
        e.Header = "Sample header";

    Although this example just updates a textblock, you can use it for other methods. I hope this helps you achieve what you're looking for.

    Good Luck,

  3. Enrico
    Enrico avatar
    14 posts
    Member since:
    Mar 2011

    Posted 07 Jun 2012 Link to this post

    Thanks for answering, but I don't know how this can help me to get around my problem.
    Once again my problem is that the TrackBallInfoControl doesn't show up when I touch the screen, since I have IsManipulationEnabled on the chart. What I want is to touch the screen and see the TrackBallInfoControl.
    Furthermore I want to touch the TrackBallInfoControl and move it along the chart, just like I would move the cursor on the chart via Mouse.
    How can I achive this.

  4. Petar Marchev
    Petar Marchev avatar
    996 posts

    Posted 08 Jun 2012 Link to this post

    Hello Enrico,

    It is not possible to control the Track-Ball from code. The current implementation of the ChartView only handles mouse events to navigate the Track-Ball and it does not handle any of the touch manipulation events. So, unfortunately, presently it is not possible to achieve this scenario.

    We have plans to introduce a new touch-based theme in which we will consider to support such a functionality out-of-the-box. We are sorry for the caused inconvenience, let us know if we can assist you further. 

    Kind regards,
    Petar Marchev
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  5. MikeWiese
    MikeWiese avatar
    43 posts
    Member since:
    Apr 2007

    Posted 29 Jun 2012 Link to this post

    For other googlers coming in here: I found that the TrackInfoUpdated event doesn't fire unless you have ShowTrackInfo="True"
Back to Top