I'd like to be able to customize the data in the TrackBall popup. I see there's an example of how to customize the header (http://www.telerik.com/help/silverlight/radchartview-features-trackball.html), but I'd like to be able to customize the Value label to say Counts and Category to say Energy. Also I'd like to do use a converter, or some math on the values for the Value and Category. How can this be done?
Thanks!
5 Answers, 1 is accepted
The chart series expose a TrackBallInfoTemplate through which you can customize the series specific information in the Track ball information panel. Here is an example:
<
telerik:RadCartesianChart
>
<
telerik:RadCartesianChart.Resources
>
<
sys:String
x:Key
=
"categoryFormat"
>Category: {0}</
sys:String
>
<
sys:String
x:Key
=
"valueFormat"
>Value: {0}</
sys:String
>
<
DataTemplate
x:Key
=
"seriesTrackBallInfoTemplate"
>
<
StackPanel
Orientation
=
"Vertical"
>
<
TextBlock
Text="{Binding
Path
=
DataPoint
.Category,
StringFormat={StaticResource categoryFormat}}"/>
<
TextBlock
Text="{Binding
Path
=
DataPoint
.Value,
StringFormat={StaticResource valueFormat}}"/>
</
StackPanel
>
</
DataTemplate
>
</
telerik:RadCartesianChart.Resources
>
<
telerik:RadCartesianChart.Series
>
<
telerik:LineSeries
TrackBallInfoTemplate
=
"{StaticResource seriesTrackBallInfoTemplate}"
/>
</
telerik:RadCartesianChart.Series
>
I hope this helps.
Best regards,
Petar Kirov
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
Please can u suggests how to add customize data template in area series TrackBallInfoTemplate property on code behind.My sample code that i have written in view model:-
private static void OnSeriesTypeChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{
RadCartesianChart chart = sender as RadCartesianChart;
if (chart == null)
return;
chart.Series.Clear();
QueryableCollectionView qcv = new QueryableCollectionView(DetailsModel.lstItems);
qcv.GroupDescriptors.Add(new GroupDescriptor() { Member = "LocationCode" });
foreach (var group in qcv.Groups)
{
var AreaSeries = new AreaSeries();
AreaSeries.ValueBinding = new PropertyNameDataPointBinding("Qunatity");
AreaSeries.CategoryBinding = new PropertyNameDataPointBinding("TransactionDate");
AreaSeries.SetBinding(CategoricalSeries.ShowLabelsProperty, new Binding("ShowLabels"));
AreaSeries.ItemsSource = group as IEnumerable;
AreaSeries.CombineMode = ChartSeriesCombineMode.Stack;
AreaSeries.LegendSettings = new SeriesLegendSettings();
//AreaSeries.TrackBallInfoTemplate ???please sugget how to set this
AreaSeries.LegendSettings.SetValue(SeriesLegendSettings.TitleProperty, Convert.ToString((((Telerik.Windows.Data.QueryableCollectionViewGroup)(group))).Key));
chart.Series.Add(AreaSeries);
}
chart.HorizontalAxis.Title = "TransactionDate";
chart.VerticalAxis.Title = "Quantity";
CategoricalAxis categoricalAxis = chart.HorizontalAxis as CategoricalAxis;
if (categoricalAxis != null)
{
AxisPlotMode plotMode = AxisPlotMode.BetweenTicks;
plotMode = AxisPlotMode.OnTicks;
categoricalAxis.PlotMode = plotMode;
}
}
You can either have your track ball template declared in the user control's resources and find them from code behind so you can set them to the series:
var tbiTemplate =
this
.Resources[
"TrackBallInfoTemplate"
]
as
DataTemplate;
this
.cartesianChart.Series[0].TrackBallInfoTemplate = tbiTemplate;
Contrary you can have the data template parsed in C# code:
string dataTemplateString = @"
<
DataTemplate
x:Key
=
"seriesTrackBallInfoTemplate"
>
<
StackPanel
Orientation
=
"Vertical"
>
<
TextBlock
Text="{Binding
Path
=
DataPoint
.Category,
StringFormat='{}{0} Category}"/>
<
TextBlock
Text="{Binding
Path
=
DataPoint
.Value,
StringFormat='{}{0} Value}">
</
StackPanel
>
</
DataTemplate
>";
var tbiTemplate = System.Windows.Markup.XamlReader.Load(dataTemplateString) as DataTemplate;
Regards,
EvgeniaTelerik
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
I believe that the following approach will meet your requirements - the trackball position might follow the mouse cursor. Whenever you move the mouse upward or downward, the trackball will move accordingly so that it does not hide your series.
You may find attached a sample that demonstrates what I mean. Let me know how it works.
Evgenia
Telerik
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.