I am looking to a solution to this post that uses CategoryDateTimeXAxis:
http://ko.infragistics.com/community/forums/t/52624.aspx
The example works but, unfortunately, CategoryXAxis requires all series on the chart to have all x-values "aligned", so if I have two series that do not have completely matching times for the x-axis data, the second series will not be rendered (see http://ko.infragistics.com/community/forums/p/38082/220246.aspx). I tried to drop in a CategoryDateTimeXAxis in the example since it allows "non-aligned" x-values but that doesn't work - for example, simply changing this:
<igChart:CategoryXAxis x:Name="xAxis" ItemsSource="{StaticResource data}">
to this:
<igChart:CategoryDateTimeXAxis x:Name="xAxis" ItemsSource="{StaticResource data}" DateTimeMemberPath="Date">
does not work. Any suggestions on how to alter the referred posts' example for this type of X-Axis?
Hello Gary,
Thank you for your feedback. I am glad I was able to assist you on this matter.
Sincerely,AndrewAssociate DeveloperInfragistics Inc.www.infragistics.com/support
Thanks Andrew, your suggestion works. Based on your investigation, I took a look at the Axis Label data template that contains the DateLabel binding. I realized that is the point where the Date is being truncated to the whole day (as you indicated) and made this change:
<Window.Resources> <DataTemplate x:Key="labelTemplate"> <local:DateLabel Date="{Binding Item.Date}" Chart="{Binding Axis.Chart}"/> </DataTemplate> </Window.Resources>
to:
<Window.Resources> <DataTemplate x:Key="labelTemplate"> <local:DateLabel Date="{Binding Item}" Chart="{Binding Axis.Chart}"/> </DataTemplate> </Window.Resources>
Since "Item" is the actual DateTime value, when I specify "Item.Date", that truncates the date to the whole day and that is the value that gets set on the DateLabel object. Removing that part of the binding (effectively binding to the wrong property) solves my issue as well. Thanks for the quick analysis!
I have been investigating into this, and I have been able to reproduce this issue that you are seeing. It appears that this issue is mainly coming from the setting of the Date property on the DateLabel class, as when it is set in the OnDateChanged method, it appears that this property is set to the correct day, month, and year, but the time is set to 12:00AM. In other words, it appears that the binding is not respecting the time of the Date when it is bound in this case.
To work around this, I would recommend a modification to the Loaded event of the DateLabel, which was implemented earlier in this discussion. In this Loaded event, you can cast the sender of the event to a DateLabel object and get its DataContext, which in this case will be an AxisItemDataContext element. This AxisItemDataContext has an Item property, which will be the correct date with the correct time. I would recommend that you retrieve this date, and then set this.Date (the DateLabel's Date property) to that DateTime object. Then you can make the call to Update(), since the Update() method uses this Date property.
I have attached a modified version of the sample project you sent to demonstrate the above. I hope this helps you.
Please let me know if you have any other questions or concerns on this matter.
Hi Andrew, one thing did pop up here: When you zoom in to a "hours level", you only see 12:00 as labels. This seems to be due to the GetDateLabels() call not providing dates that are more precise than a day. Not sure how to get this to provide tickmarks showing correct hours, min, etc. when zooming into that level as it isn't clear to me what is providing the actual date values for each tick. Seems like the Axis is providing these values.
Your version works but my attached version using a code behind does not.
Thanks Andrew, the charting app I am working on dynamically creates most of the chart components, including the axes, in the code behind, so I had some initial issues using a dynamically created CategoryDateTimeXAxis, but I was able to switch this to be static and things are now operating as expected.
Thanks!