different colors in a line series


https://www.nevron.com/Forum/Topic12665.aspx
Print Topic | Close Window

By Manal Goyal - 6 Years Ago
Hi,
I have a LineSeries which goes from -2 to 2 on x axis, I want to color the part of the series from -2 to 0 on x axis in red and the part from 0 to 2 in blue. How can I achieve that.

Thank you.
By Nevron Support - 5 Years Ago
Hi Manal,
You can assign different stroke style per line segment using the BorderStyles collection of the series - for example:
   NChart chart = nChartControl1.Charts[0];
    NLineSeries line = new NLineSeries();

    line.Values.Add(1);
    line.BorderStyles[0] = new NStrokeStyle(Color.Red);
    line.Values.Add(2);
    line.Values.Add(3);

    chart.Series.Add(line);
will draw a line where the first segment is in different color.