Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
160
CategoryDateTimeXAxis: ItemsSource Property
posted

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

Parents
  • 30692
    Suggested Answer
    Offline posted

    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

Reply Children