I have a Chart on a ASP.NET Web Forms report. The customer wants to see datetimes displayed in local time with no offset. However, we need the offset to prevent weird chart behaviors during Daylight Savings Time.
One solution would be to have the Value be a UTC DateTime field and the Text be a local DateTime field. Can I do this with Telerik charts? I do not see a way to set the Value and Text of each data point in the LineSeries.
7 Answers, 1 is accepted
By Chart I mean Graph.
Sorry for double posting. I cannot figure out how to edit my original post.
If you are using a DateTime scale in your Graph, then the displayed dates are the ones used to bind and process the data and you do not have control over them - you can just apply some formatting using the LabelFormat property.
However, if you use a Category scale to represent the dates, you can change the displayed labels using an expression or a custom UserFunction. This can be done through the CategoryGroup.Label property.
Please note that if you use a Category scale to display dates, the shown interval will not be continuous and the graph will display each data points in its own category slot, equally offset from its surrounding members.
Hope it helps.
Regards,
Ivan Hristov
Telerik
Hello Ivan,
I tried using a DateTime sca le and applying a formatting to the Labels to hide the offset. I could not get the graphs to bind to a DateTimeOffset field. Is this possible? I may be able to convince the customer that we need to show the offset on the graph, if that is what it takes to make the points show up correctly.
If there are gaps in the data, then we need the gaps to show up. The Category scale doesn't show gaps. We thought about solving this problem by adding fake points to fill in the gaps, but we couldn't figure out how to make the points not show up, so we scrapped that solution. Also, the Category scale doesn't appear to have a skip, so if there are a thousand data points, we end up with a thousand labels.
For reference, the attached image, Good.PNG, is what the customer wants. I was able to make this graph using a Category scale using a small amount of data that had no gaps.
The other attached image, Bad.PNG, was just an experiment. This is why Telerik needs to get away from using DateTimes and start supporting DateTimeOffsets. Can you imagine trying to explain to a customer why their graph suddenly doubled over during Daylight Savings Time?
Update:
I tried to create my own DateTimeOffsetScale that inherited from ScaleBase, but ScaleBase is internal, so that did not compile.
As another experiment, I created a scale that inherited from DateTimeScale and override nothing at all. It was just an empty class. I made my graph use that scale, and I got "An error has occurred while processing Graph 'myTestGraph': Unknown scale: MyCustomScale".
Looking at the provided screenshots, one might assume that the good one is misleading - you have points with the same label on different places on your X axis. Again, the DateTime scale performs as expected on the bad screenshot - it duplicates the data points where the datetime values are the same.
Since your data is not suitable to show on a Category scale, the solution is to get the dates in UTC time and use the DateTime scale.
ScaleBase and virtually all the classes used by the Graph item are intended for internal use and are not supposed to be accessed and/or modified. Also when you introduce a custom class in the report definition, it is not recognized by the processing engine - that's why you receive the "Unknown scale" message.
Let us know if you have more questions.
Regards,
Ivan Hristov
Telerik
Ivan,
Converting the data to UTC is not the solution. I cannot tell customers, "The timestamps on your graphs may be zero to twelve hours off from your local time." The timestamps must be in local time.
You mentioned that the duplicate labels were misleading. I agree. They would not be misleading if they had an offset. Perhaps even more misleading is the second image, which is all Telerik supports right now. Did we go back in time? No, of course not. Daylight Savings Time is merely a time zone change, and Telerik does not all for this.
Put simply: Telerik only supports DateTimes. DateTimes are ambiguous. Therefore, Telerik only supports ambiguity. DateTimeOffsets are unambiguous, but Telerik does not support them.
You are correct that the Telerik Reporting Graph item does not support a DateTimeOffset scale. If you would like to see this feature implemented in the future please post a feature request in our Ideas & Feedback portal. Depending on the number of votes for a feature and its feasibility we adjust its priority and add the most popular features to our roadmap.
Regards,
Nasko
Telerik