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

DateTimeContinuousAxis, show another label instead x datetime values

1 Answer 108 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
malabareand asked on 14 Oct 2014, 08:22 PM
Hello everyone!  

Im drawing a chart with RadCartesianCharts, and i have to display another value (age) instead custom x value datetime 

the structure for each point series is:

  DateTime DateMeasure { get: set; }
  decimal    Height  { get: set; }
  decimal    Age  { get: set; }

and i'm using the following  horizontalAxis configuration:

  <chartView:DateTimeContinuousAxis LabelFitMode="Rotate"
                      LabelFormat="{Binding AxisXformat}"
                      Visibility="{Binding VisibilityAxis}"
                      Title="{Binding TitleX}" />

 and the code where i'm making series

var edadSeries = new LineSeries(){
              ItemsSource = vm.PersonAge,
              Visibility = System.Windows.Visibility.Visible,
             //here is where i'm binding the date, but i would like to bind the "Age" property
             //AnotherCategoryBinding = new PropertyNameDataPointBinding() { PropertyName = "Age" },
             CategoryBinding = new PropertyNameDataPointBinding() { PropertyName = "DateMeasure" },
             ValueBinding = new PropertyNameDataPointBinding() { PropertyName = "Height" },
             BorderBrush = System.Windows.Media.Brushes.Black,
             BorderThickness = new Thickness(1),

another solution, could be show only x (datetime) values for datapoint in x axis for try to cheat in another way


1 Answer, 1 is accepted

Sort by
Martin Ivanov
Telerik team
answered on 17 Oct 2014, 11:11 AM
Hi Carlos,

Keep in mind that the labels of the Cartesian chart's axes are not related with the data points that are plotted on the chart. Which means that you cannot get directly the Age property from your view models and use it in the label. 

If you want to show decimal values (in your case, Age) you can consider using another type of axis. For example, a LinearAxis and ScatterLineSeries.

Another approach you can try is to define a LabelTemplate for the DateTimeContinuousAxis and use an IValueConverter in the text's binding to convert the DateTime string in the label to a specific decimal value.

            <TextBlock Text="{Binding Converter={StaticResource DateStringToAgeConverter}}" />

You can also try to implement custom labels with chart's annotations. Basically, you can hide the axis and then use CartesianCustomAnnotation with a Rectangle (for the ticks) and TextBlock (for the labels) in its ContentTemplate.

Please let me know if you need any further assistance.


Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Asked by
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question