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

TrackBall Info Template Decimal Places

3 Answers 39 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Gareth
Top achievements
Rank 1
Gareth asked on 07 Jan 2016, 03:20 PM

I'm trying to format the String output for my Series Trackball so that it only shows 2 decimal places.  The code I have at the moment for my Template is as follows:

<telerik:RadCartesianChart.Resources>
<sys:String x:Key="CategoryFormat">Date: {0}</sys:String>
<sys:String x:Key="ValueFormat">Value: {0:n2}</sys:String>
                                                 
<DataTemplate x:Key="seriesTrackBallInfoTemplate">
      <StackPanel Orientation="Vertical">
       <TextBlock Text="{Binding Path=MeasurementData.Category, StringFormat={StaticResource CategoryFormat}}" />
        <TextBlock Text="{Binding Path=MeasurementData.Value, StringFormat={StaticResource ValueFormat}}" />
        </StackPanel>
</DataTemplate>
 </telerik:RadCartesianChart.Resources>

The type of MeasurementData.Value is Double.

I've tried various approaches and nothing seems to work.

Any suggestions?

 

 

3 Answers, 1 is accepted

Sort by
0
Gareth
Top achievements
Rank 1
answered on 07 Jan 2016, 03:27 PM
Nevermind.  Used a Double to String Converter and put my formatter settings in there.
0
Gareth
Top achievements
Rank 1
answered on 07 Jan 2016, 03:51 PM
Turns out that didn't work either. Is it possible to edit the DisplayContent of the TrackballInfoTemplate to remove the huge amounts of decimal points?
0
Accepted
Ivan
Telerik team
answered on 11 Jan 2016, 01:31 PM
Hello Gareth,

As we look at your code and the picture it seems that the TrackballInfoTemplate is not applied and the series is using its default template. 

Also, keep in mind that the DataContext passed in the template is not the view model of the data point, but an object of type DataPointInfo. So, in order to get your view model you can use the following syntax:
<TextBlock Text="{Binding Path=DataPoint.DataItem.Value}" />
You can also take a look at the attached project where this approach is demonstrated.
 
Please let us know if this solution works for you.

Regards,
Ivan
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
ChartView
Asked by
Gareth
Top achievements
Rank 1
Answers by
Gareth
Top achievements
Rank 1
Ivan
Telerik team
Share this question
or