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,
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.
[Solved]
Hi,
I am stuck, i do not success to make a chart with two data collection on datetime axis, with a different number of items on different datetime.
Can you send an example of Chart with two different data collection 2 CategoryDateTimeXAxis + 2 NumericYAxis binding in codebehind on 2 Observablecollection.
Common data collection structure:
public class GraphDataPoint { public DateTime Label { get; set; } public double Value { get; set; } }
Also Same question as VaibhavChadia.
Jean-Luc
Urgent : Has this feature been added in the 2011.2 release i.e. Multiple data series (from multiple sources) sharing the same X Axis?
Excellent, thanks Francis!