Hi,
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?
Cheers,
Enrico
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?
Cheers,
Enrico
4 Answers, 1 is accepted
0
Lancelot
Top achievements
Rank 1
answered on 06 Jun 2012, 06:55 PM
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.
XAML
And now here is the c# event handler...
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,
Lancelot
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.
XAML
<
telerikChart:RadCartesianChart
>
<
telerikChart:RadCartesianChart.TrackBallInfoStyle
>
<
Style
TargetType
=
"telerik:TrackBallInfoControl"
>
<
Setter
Property
=
"HeaderTemplate"
>
<
Setter.Value
>
<
DataTemplate
>
<
TextBlock
Text
=
"{Binding}"
FontSize
=
"23"
Foreground
=
"Green"
/>
</
DataTemplate
>
</
Setter.Value
>
</
Setter
>
</
Style
>
</
telerikChart:RadCartesianChart.TrackBallInfoStyle
>
<
telerikChart:RadCartesianChart.Behaviors
>
<
telerikChart:ChartTrackBallBehavior
ShowTrackInfo
=
"True"
ShowIntersectionPoints
=
"True"
TrackInfoUpdated
=
"ChartTrackBallBehavior_TrackInfoUpdated"
/>
</
telerikChart:RadCartesianChart.Behaviors
>
<
telerikChart:RadCartesianChart.VerticalAxis
>
<
telerikChart:LinearAxis
/>
</
telerikChart:RadCartesianChart.VerticalAxis
>
<
telerikChart:RadCartesianChart.HorizontalAxis
>
<
telerikChart:CategoricalAxis
/>
</
telerikChart:RadCartesianChart.HorizontalAxis
>
<
telerikChart:SplineSeries
>
<
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"
/>
</
telerikChart:SplineSeries
>
<
telerikChart:LineSeries
>
<
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"
/>
</
telerikChart:LineSeries
>
</
telerikChart:RadCartesianChart
>
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,
Lancelot
0
Enrico
Top achievements
Rank 1
answered on 07 Jun 2012, 02:04 PM
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.
Thanks.
Enrico
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.
Thanks.
Enrico
0
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
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 >>
0
MikeWiese
Top achievements
Rank 1
answered on 29 Jun 2012, 10:29 AM
For other googlers coming in here: I found that the TrackInfoUpdated event doesn't fire unless you have ShowTrackInfo="True"