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

Graph datetimescale axis issue

1 Answer 110 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Rebecca
Top achievements
Rank 1
Rebecca asked on 09 Jan 2014, 01:38 AM
Hello,
I've created a Graph with the x-axis of datetimescale type and attached a datatable as the data source.
This works ok, but there's a catch.
The dates I want to show on the x-axis aren't all inclusive, i.e. I have a datatable with just weekday dates shown for the month of January, the weekend dates are removed.
However, the Graph, very "helpfully" has "fixed" that "error" of mine and inserts the weekend dates onto the axis anyway.
How can I suppress this behaviour programmatically? I don't want to show weekend dates on my axis. I only want those dates in the datatable to be shown. I don't want to convert the dates to a string, because when I do, it very "helpfully" shows the full date/time format, so for example 01/01/2013 comes out like "01/01/2013 00:00:00.00000", so it needs to be left as a datetimescale type.
I am not using the report designer to create this Graph. I am creating it programmatically using VB.NET.
I've put the snippet where I create the graph axis below.
Thanks,
Rebecca

Dim graphaxiscatscale As New GraphAxis()
graphaxiscatscale.Name = "GraphAxis1"
graphaxiscatscale.Scale = New DateTimeScale()
graphaxiscatscale.LabelAngle = 90
graphaxiscatscale.LabelFormat = "{0:d}"

1 Answer, 1 is accepted

Sort by
0
Ivan Hristov
Telerik team
answered on 10 Jan 2014, 04:13 PM
Hi Rebecca,

The purpose of the DateTime Scale is to display dates in chronological order at specific intervals or base units, even if the dates from the data source are not in order or in the same base units. In other words, it represents a period of time in a continuous manner, that's why the observed behavior is expected.

To achieve the desired output we can suggest you to do the following:
  • Use a CategoryScale for your X axis.
  • Add a grouping to the CategoryGroup by your DateTime field.
  • Set the CategoryGroup.Label property to "= Fields.DateTime.ToString('dd/MM/yyyy')"

Please note that the Category Scale will display your date time values in an unordered manner, so you may have to sort the data.

Hope it helps.

Regards,
Ivan Hristov
Telerik

New HTML5/JS REPORT VIEWER with MOBILE AND TOUCH SUPPORT available in Telerik Reporting Q3 2013! Get the new Reporting version from your account or download a trial.

Tags
General Discussions
Asked by
Rebecca
Top achievements
Rank 1
Answers by
Ivan Hristov
Telerik team
Share this question
or