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,
I have been investigating this a bit further, and it appears that what is happening is that when using the CategoryDateTimeXAxis rather than the CategoryXAxis, then when the code inside of the Chart_RefreshCompleted handler is called, essentially what is happening is that the shell that will hold the labels is there, but the data inside of them has not been updated yet. In other words, the labels are not fully loaded yet, and hence the date on each of them is returning 1/1/0001, when retrieved in the GetDateLabels method.
To get around this, I would recommend removal of the SetupEvents, CleanupEvents, and Chart_RefreshCompleted methods from the DateLabel class. This will remove the Update method from being called, and I would recommend placing a handler for the Loaded event of the DateLabel inside of the constructor for the DateLabel. Inside of the event handler for the Loaded event of the DateLabel, you can call the Update method, as the DateLabel objects will now be Loaded and populated with the correct data. When zooming in and out on the XamDataChart, the Loaded event will fire again as the chart will need to redraw, and so the labels will be redrawn and reloaded as well.
I have attached a modified version of the sample that was on the other forum thread to this thread to demonstrate the above.
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate DeveloperInfragistics Inc.www.infragistics.com/support
Thanks for looking at this. If you can post a working example when ready, that will be most helpful.
Thanks!
Thank you for your post!
I have been investigating into this issue, and it appears that with the current bindings on the DateLabel object that now represents the CategoryDateTimeXAxis's Label, you should be getting a large amount of binding expression errors in the Visual Studio output window. This is being caused due to the ElementName binding to find the Chart property of the DateLabel object. To get around this, rather than using an ElementName binding, you can use the following: {Binding Axis.Chart}.
The above fixes the binding errors, but the labels still do not render. This appears to be a timing issue with the XamDataChart and the axis being created, but I am not entirely sure as of yet. One thing that is rather disturbing about this is that the GetDateLabels() method on the DateLabel class is now returning the correct number of DateLabel objects, but each of their Date properties is set to 1/1/0001. This is also causing the AxisScale to always be returned as "Minutes" as well, which isn't correct. At the start, it should be "Years".
I am going to continue to investigate this to see what is going on here. To use this with the CategoryDateTimeXAxis, it currently appears that a different custom object may need to be constructed. I will update this forum thread again when I have more information for you.