Hello,
I am using the XamDataChart from the new release of WPF DV (v11.1).
I am having a hard time finding out how to set the property ItemsSource on CategoryDateTimeXAxis in the following case:
On a single chart (with CategoryDateTimeXAxis as X-Axis) I'd like to display two series whose sources are different. I am using the new properties MinimumValue and MaximumValue to specify the X-Axis range I want to display. Apparently, I also need to set the ItemsSource to something if I want to see series on the chart, but I have two questions regarding this:
First, what is the purpose of ItemsSource, how is it used?
Second, what should I set ItemsSource to in order to see my two series correctly drawn? (I tried to set it to different things like the source of one of the series or the concatenation of the serie' sources or a list made of only the minimum and maximum values, etc... but it did not work)
Any help will be really appreciated,
Thanks a lot,
Carole
Carole,
The ItemsSource on the CategoryDateTimeXAxis works in conjuction with the DateTimeMemberPath to alert the axis to what property on your data items represents the date value for the item. Since the CategoryDateTimeXAxis will display the points spaced depending on the amount of time between them, etc. It needs to know the Date value for each item.
So, for example, if the class for your data items looked like this:
public class DataItem
{
public double Value { get; set; }
public DateTime Date { get; set; }
}
And you had the data set up as the DataContext for the chart, you might set up your CategoryDateTimeXAxis like this:
<igChart:CategoryDateTimeXAxis x:Name="xAxis" ItemsSource="{Binding} DateTimeMemberPath="Date" Label="{Date}" />
or something of that nature.
If you have 2 different series that are using the CategoryDateTimeXAxis, it really depends on how your data is aligned and sorted. If your data is in the same order for the two series and there are the same number of items, you may be able to share the same CategoryDateTimeXAxis, otherwise, you will need to create a CategoryDateTimeXAxis for each series (binding the same data to the itemssource for each as the itemssource for the series). Then, to make the time spans align, you should set the minimum and maximum values for each CategoryDateTimeXAxis to be equal.
I hope this helps. Please ask me to elaborate if something is unclear.
-Graham
Hi Graham,
Thanks a lot for your quick reply. Everything is clear, thank you.
I have last question about that: I understand that is possible to define multiple axis and hence plotting many series on the same chart. However, from a user perspective it would be very nice to be able to share the same CategoryDateTimeXAxis among many series that contains the same type of item (for comparison purpose for instance). Is this something that Infragistics is planning on implementing in the future?
Thanks a lot,Carole
CategoryDateTimeXAxis can be shared among series. I am attaching a small sample here that demonstrates it.
Thank you,Sam
Hi Sam,
Thanks for your reply.
I had a look at your solution but this is not what I am looking for. In your example you do a binding using the same series as a source. What I want is being able to share one CategoryDateTimeXAxis through different line series, so different sources.
I attached back the project, in the class SecondWindow, I added two different line series (one with more points than the others). If you have a look you'll see first that when setting the itemssource of the CategoryDateTimeXAxis to the 1st line series, then part of the 2nd lineseries is not drawn. Then, when setting it to the 2nd line series, it crashes.
Also, something interesting, try removing the first three points of the 2nd lineseries, you can see that the series is shifted to the left.
Please let me know, if there is another solution,
Thanks,
Kind regards,
If you have two different data series for the CategoryDateTimeXAxis then, like as not, you will need two seperate CategoryDateTimeXAxes with each associated with a different source. To make the data align, you will need to manually set the min and max to be the same for each axis. Otherwise the axes will take the min and max date from the data series, so may potentially have different alignments. You can then also hide the extraneous axis by setting its strokes to transparent, and setting its axis labels to collapsed.
This is the only method currently to easily plot multiple date time data against eachother. If you can describe how you would like the axis sharing to work for this type of axis, we can accept it as a feature request. If you have any questions about how to implement using the above strategy. Let us know.
Hope this helps!
Can you please share example solution for case when we have two different data series.We set different sources for 2 CategoryDateTimeXAxes and Display only one x axis.