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

How can I get a Telerik Reporting graph to sort the x-axis by a date and format that date?

1 Answer 301 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 1
Dan asked on 05 May 2016, 06:54 PM

 

 

I have a Telerik report with a graph. The graph's x-axis is a series of dates. Our client would like those dates in order from oldest to most recent. They also want the dates formatted to not include the time portion of the date. I've tried for the past day to get this to work and can't figure it out. Can someone explain how to do this?

My data query is this

SELECT AnalysisNumber
    , DateSampled
    , ViscosityAt100C
FROM tblSample
ORDER BY a.DateSampled ASC

The results show the dates in the order I want them and the dates are formatted properly.

 

AnalysisNumber   DateSampled        ViscosityAt100C
2146951               2015-12-17           13.5
2148323               2015-12-30           12.8
2149080               2016-01-11            13.9
2152284               2016-02-03            13.3
2153660               2016-02-18            13.6
2158736               2016-03-09            13.7
2158737               2016-03-16            13.8

 

But when the graph is displayed, the dates show with the time: 12/17/2015 12:00 a.m.  I've set the LabelFormat to {0:d}, but the time portion of the date still shows.  I've tried several formats there, but done seem to change it at all.

 

I tried to convert the date to a varchar and format it, but then the dates are not in the proper order.  I also tried having a text version of the date and a date version of the date in my SQL query, using the text version as the grouping and the date version as the sorting, but that resulted in not showing anything on the x-axis.

 

How do I get the dates to be formatted properly but still sorted like a date?

For a fuller explanation with screenshots, look at this: Formatting dates on graph


I have a Telerik report with a graph. The graph's x-axis is a series of dates. Our client would like those dates in order from oldest to most recent. They also want the dates formatted to not include the time portion of the date. I've tried for the past day to get this to work and can't figure it out. Can someone explain how to do this?

I have a Telerik report with a graph. The graph's x-axis is a series of dates. Our client would like those dates in order from oldest to most recent. They also want the dates formatted to not include the time portion of the date. I've tried for the past day to get this to work and can't figure it out. Can someone explain how to do this?

1 Answer, 1 is accepted

Sort by
0
Ivan Hristov
Telerik team
answered on 10 May 2016, 07:33 AM
Hello Dan,

While examining the attached screenshots, we noticed that you're probably using a Category Scale for your X axis. In this case the date format will not be applied, because the category scale treats its labels as strings, not as dates. We can suggest you to switch to a DateTime scale, which is designed specifically to display dates in chronological order - you can check this article that elaborates on the subject.

However, if you would like to keep using the Category scale, you can format the axis labels using the Label property of your category group, using the following expression: =Format('{0:d}', Fields.DateSampled)

Hope it helps.

Regards,
Ivan Hristov
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
General Discussions
Asked by
Dan
Top achievements
Rank 1
Answers by
Ivan Hristov
Telerik team
Share this question
or