I have a time x-axis that I can zoom in and scroll. I would like to ensure that my label are aligned with specified interval.
For example, if my data start at 1:53 and ends at 11:03, I would like to display labels at every hour but aligned on rounded hours (2:00 to 11:00 in that case). How I do that ?
Using "smart labels" does not properly works and give the expected result when initial time or duration is not already aligned. It seems that the first label is always at the axis beginning.
Using data interval does not solve completly the problem. I can compute the interval that I prefer but I haven't found how to specify where the labels should strart to be displayed (i.e. display the first label at 2:00 in the example above).
If the range is greater than one day or there is a date change during the displayed period, I like to display the date on every day changes. For ranges that are less than 2 days, I expect to also display time in HH:mm format (except on day changes).
In the source code, there seem to be a TickAlign property that might be what I need (except for custom formatting of the time but that part is explained elsewhere but using a renderer - I have not tried it yet) and would allows me to ensure that times are aligned properly according to the tickmark span and that dae are displayed at midnight.
Also, when there is a daylight saving time change (for ex. 9 march this year), will I be able to properly display local time and display date at midnight even though one day might be 23 hours long or 25 hours long ?
Philippe
thanks for the suggestions, we'll take them under consideration next time we look at new features for axis labels. you can also submit your feature request here: http://devcenter.infragistics.com/protected/requestfeature.aspx
This is not exactly what I want since I still want the data to start at 1:53 but display the first label at 2:00.
Finally the way I have done it is to have 2 overlapping axis. The first one with the full range is used to display the data but not labels or tickmarks and could start at an arbitrary time and allows zooming and scaling. Then I use another axis with data margins set in percentage (in data value, it does not give the expected result) to display labels and grid. When the user changes the zoom factor or scroll data, I compute a new aligned start and end time and the required data margin (in %) for that axis so that it stay synchrozined with the main one.
There is a minor limitation with this method if we want to display minor tickmarks (grid) as it would require a third axis in case one minor tickmark occurs before the major one. Another limitation is that even if there is place to display start (or end) label (for ex. 1:53, 2:00 3:00, 4:00 etc...), it would not be easy to determine if 1:53 (from main axis) would overlap 2:00 (from the other overlapped axis).
It would be nice if Infragistics would allows us to specify how to align labels and not force the first label to be at the start of the range. In fact, if it would be handled by Infragistics, there could be some options like :
In fact, it would also be nice to be able to be able to uses user-provided algorithm to get the position (and value) of labels.
For the rendering I do uses IRenderLabel to display date at midnight (instead of time) and to display long time instead of short time if the span between label is less than one minute.
This will partly handle daylight time change... if I display more than one day, because label are regulary spaced. So I might have (assuming 6 hours interval) : DATE - 7:00 - 13:00 - 20:00 - 1:00 on the day where daylight saving occurs. I would prefer to have one interval shorter or longer to realign subsequent labels (well if the interval is shorter the the label may overlap the previous one... so we might want to skip one label)
Presently the only way to achieve this would be to use additionnal axis with appropriate data margins, ranges and options (visibility of labels, grids etc...). Presently I haven't implement such an option so if I display one week of data starting at the last day before daylight saving chages, I would have the date for the first label and 23:00 or 1:00 at the following 24 hours intervals.
Thus it would be much simpler if Infragistics would provide a way to implement our algorithm for major (and minor) tickmarks. Not only it would be usefull in that case but anytime someone would like to display special scales that is neither purely linear or logarithmic.
you can set the axis minimum to 2:00 using this code:
Axis.X.RangeType = Custom
Axis.X.RangeMin = DateTime.Parse("1/1/2001 2:00:00 AM").Ticks;
Axis.X.RangeMax = DateTime.Parse("1/1/2001 4:00:00 AM").Ticks;
as for the daylight savings time issue, i think it will display properly because the axis uses the .NET DateTime struct and this should be inherently supported ... but i haven't actually seen an example which showed this, so i can't say for sure if it works properly.