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
215
Chart with multiple series from ObservableCollection<ObservableCollection<PriceDataHistory>>
posted

I'm still new to WPF, Data Binding, Infragistics, and reallly GUI Windows Development... Sometimes I find working with the XamDataChart a little confusing for displaying complex objects, but I think it falls down to my understanding of how the XAML Binding Works with the charting package.

I have

public class PriceDataHistory ObservableCollection<Price>

Price is a custom object that looks like:

    public class Price
    {
        public string Country { getset; }
        public string LocationCode { getset; }
        public DateTime Date { getset; }
        public double Price { getset; }
    }

I have many data points in the Observable collection and I would like to display them grouped by LocationCode.

So, for example If I have three different locations I would like to display 3 series on the chart.

   
   public class PriceDataHistory ObservableCollection<Price>
    {         public PriceDataHistory()         {             for (int i = 0; i < _priceDates.Count; i++)             {                 this.Add(new Price                 {                     LocationCode = _location[0],                     Date = DateTime.Parse(_priceDates[i]),                     Price = float.Parse(_price0[i])                 });                 this.Add(new Price                 {                     LocationCode = _location[1],                     Date = DateTime.Parse(_priceDates[i]),                     Price = float.Parse(_price1[i])                 });                 this.Add(new Price                 {                     LocationCode = _location[2],                     Date = DateTime.Parse(_priceDates[i]),                     Price = float.Parse(_price2[i])                 });             }         }
        ///... not necessary for example
    }

In the example data they all have the same number of points

and they all have the same Date.

In the future I will not know how many different

LocationCodes there will be, because I'm using test

data right now so it is static.

 

Is what I want even possible? How should I go about

binding to my object in XAML?

Parents Reply Children
No Data