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

[Solved] Date Formatting in DateTimeContinuousAxis

1 Answer 279 Views
Chart for XAML
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Andy Macourek
Top achievements
Rank 1
Andy Macourek asked on 30 Oct 2012, 04:33 PM

I have a chart rendering based on my data, but I am having an issue with the date not formatting on the x-axis. If I do not apply formatting, the date shows as a full string, but I only want the hour and minute to show.  The XData datatype is DateTime.

<DataTemplate>
<telerik:RadCartesianChart Width="700" Height="200">
<telerik:RadCartesianChart.HorizontalAxis>
<telerik:DateTimeContinuousAxis LabelFitMode="None" LabelFormat="hh:mm" >
</telerik:DateTimeContinuousAxis>
</telerik:RadCartesianChart.HorizontalAxis>
<telerik:RadCartesianChart.VerticalAxis>
<telerik:LinearAxis/>
</telerik:RadCartesianChart.VerticalAxis>
<telerik:LineSeries ItemsSource="{Binding ChartData}">
<telerik:LineSeries.ValueBinding>
<telerik:PropertyNameDataPointBinding PropertyName="YData"></telerik:PropertyNameDataPointBinding>
</telerik:LineSeries.ValueBinding>
<telerik:LineSeries.CategoryBinding>
<telerik:PropertyNameDataPointBinding PropertyName="XData"></telerik:PropertyNameDataPointBinding>
</telerik:LineSeries.CategoryBinding>
</telerik:LineSeries>
</telerik:RadCartesianChart>
</DataTemplate>


The problem is that all the labels are just the string "hh:mm"

1 Answer, 1 is accepted

Sort by
0
Ivaylo Gergov
Telerik team
answered on 31 Oct 2012, 09:24 AM
Hello, Andy 

Thank you for using our RadControls for Windows 8!

In order to achieve this result you have to use the following formatting pattern (following the String.Format routine):

LabelFormat="{}{0:hh:mm}"

More information may be found in this documentation article (LabelFormat property):

http://www.telerik.com/help/windows-8-xaml/radchart-axes-axis.html

I hope this helps. If you have any further questions do not hesitate to contact us again.

All the best,
Ivaylo Gergov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Chart for XAML
Asked by
Andy Macourek
Top achievements
Rank 1
Answers by
Ivaylo Gergov
Telerik team
Share this question
or