Search code examples
c#wpflivecharts

How compare charts using a List<T> with LiveCharts?


I'm trying to compare a lot of charts using Live Charts according with the numbers of classes inside my List.

I'm trying some like this:

    class MyClass 
    {
        IList<double> a;
        IList<double> b;
    }

And to make a chart:

    List<MyClass> aLotOfCharts = new List<MyClass>

    for(int i=0; i < aLotOfCharts.Count; i++)
    {                    
        SeriesCollection = new SeriesCollection
        {
            new LineSeries
            {
                Values = new ChartValues<double> (aLotOfCharts[i].a)
            },
         };
    } 

I expect three charts with the "a" Data, but the actual output is only the last position of "aLotOfCharts.a".

I know I need to create more "new LineSeries" to input more charts, but I don't know how I can do this.


Solution

  • I do not know the Live Chart, but I think the answer is something like this:

    List<MyClass> aLotOfCharts = new List<MyClass>()
    SeriesCollection = new SeriesCollection()
    
    for(int i=0; i < aLotOfCharts.Count; i++)
    {
        SeriesCollection.Add(new LineSeries
                {
                    Values = new ChartValues<double> (aLotOfCharts[i].a)
                });
    }