Hello,
I am using xamDataChart for both WPF and Silverlight to display financial stocks history data. A distinguish feature of stocks data is that meaningful values do present on weekdays and no data is present for weekends. Other dates can have no data too for instance it is the stock is closed on public holidays. One of my requirements is put away any dates which have no data from the chart surface so that it would not occupy space that can be used by other data points. This approach assumes that a distance between data points is exactly 1 day (24 hours) in common except of the edge of each week.
Please notice how the dates are being displayed in the above screenshot. It shows June 3, and then June 6, skipping the 4th and 5th, and so it does for June 10 and June 14 skipping the 11th, 12th and 13th and so forth. And the distance between data points is exactly one day.
I am looking into having similar functionality in xamDataChart. I played around the CategoryDateTimeXAxis enough to have a feeling in that I can make the labels to skip the weekends by applying conditional formatting however it is not the same because the time series would still occupy the space. My another thought is to override GetScaledValue method in a way so that it would return the same scaled value for any point between Friday and Monday for instance.
My concern is if the above approach would ever affect the behavior time series so it would skip the weekends in a way that the requirement states.
Please let me know if hiding weekends functionality is possible to achieve using xamDataChart. I would appreciate if you provide any code snippets that would be very helpful.
Thanks!
Alexander
Ping Infragistics
I understand that statements like "on the backlog" are not a commitment to deliver a feature, but can we expect to see the ability to skip weekends with CategoryDateTimeXAxis anytime soon?
Many thanks
Hi Graham. Is this still on the backlog? We have an emerging requirement to skip weekends, but we have invested a lot of development effort in our CategoryDateTimeXAxis implementation and moving to a CategoryXAxis is not really viable.
As it stands, is there any way to simulate this behaviour in the current (11.2) XamDataChart? I don't mind getting my hands dirty :)
I have submitted a feature request for the same.
By the way I figured out how to convert from DateTime value to unscaled double value in CategoryXAxis. It looks like that the unscaled value is basically an index of an item in the ItemSource collection. So having a DateTime value (or whatever else) we just need to find a position of the value in the original ItemSource collection. The reverse conversion is easier because when we get an unscaled value from chart we can get corresponding DateTime (or whatever) directly using the value as an index in the ItemsSource collection.
And even if the above answer is not the common case it works for my scenario so I mark it verified.
Thanks.
Hi Graham.Thank you for the response.Using CategoryXAxis for hiding dates without data is exactly what we need in that particular scenario. However I have some other requirements that the horizontal axis should met when dealing with dates. And I have the initial implementation of that with the CategoryDateTimeXAxis class. The choice has been made because the CategoryDateTimeXAxis has a convenient way of converting unscaled double values to DateTime using DateTime(ticks) constructor. I have found this way in some other forum posts which explicitly states that it only works for the CategoryDateTimeXAxis and not the CategoryXAxis. To check that I tried DateTime(ticks) and DateTime.FromOADate with the CategoryXAxis and it really won't work - i am getting the wrond date after such a convertion.I am going to try applying the implementation that I have to CategoryXAxis and see if it works. Can you please advise how can I convert double unscaled value to the DateTime value and back with CategoryXAxis?I also attached my requirements as a text document just for the reference. I would appreciate if you could give me a tip on the best way how to do it with CategoryXAxis.Thanks.Alexander
Hi,
This is a backlog feature for the CategoryDateTimeXAxis, but isnt present currently. It will currently always make the intervening time take up space.
One option that you have currently, if you want each data point to be displayed an equal space from the last, is to use the CategoryXAxis instead of the CategoryDateTimeXAxis, and just don't include data for any days that should be skipped. This will result in each datapoint appearing an equal space form the previous, and no gaps where days have been skipped. If you assign the date property to the label of the CategoryXAxis you will see dates (which you can format as you like) on the x axis.
Does that help? Or does it not meet some of your requirements? You could submit a feature request for the date skipping for the CategoryDateTimeXAxis, to be sure that we've logged your interest in the feature, but as I said, I believe it may already on the backlog.
-Graham