Problem creating Line Series dynamically

Jan 1, 2014 at 11:47 AM
Edited Jan 1, 2014 at 11:47 AM
I am using OxyPlot to achieve few line charts using WPF C#.
Using XML :
I had created Logarithmic & Linear axis as Left & Bottom respectively and 5 line series in xml respectively. I assign each line series ItemSource as List<Point> and it works well.

Now I am to create the same thing dynamically,
I could create both axis properly. And for line series, I add it to the PlotModel as below :
    public void AddData(List<List<Point>> data, string title)
        LineSeries lineSeries;
        int ctr = 0;
        foreach (List<Point> set in data)
            // Setting the itemsource as set i.e. List<Point>
            lineSeries = new LineSeries { StrokeThickness = 5, MarkerSize = 3, Title = title + " " + ctr, ItemsSource = set };
With the above code, I get the plot, 5 titles, but no lines - I guess because somehow data is not set to Points of the line. I also tried :
lineSeries.Points = set;
but this could do as it doesn't accept List<Point>

Why is this difference between creating thru XML and code ? Why their are no lines visible ? Do I need to set or pass data in some other format ?

Can anyone please help me.
Jan 1, 2014 at 4:20 PM
I got the solution,
I need to set DataFieldX = "X", DataFieldY = "Y" in my LineSeries along with ItemSource.

Marked as answer by terry_513 on 1/1/2014 at 8:20 AM