Nevron Forum

Adding more then 1 NHighLowSeries to a same axis of same chart

https://www.nevron.com/Forum/Topic12499.aspx

By Manal Goyal - Thursday, June 14, 2018

Hi,

I need to add 2 High-Low series to the same chart, but I am only able to see one series in outer chart, is there any way I can add more then one NHighLowSeries to the same chart?
By Nevron Support - Thursday, June 14, 2018

Hi Manal,
Please elaborate on this question. The following code shows how to create a chart with two high low series:


   NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0];
   
   // set a chart title
   NLabel title = nChartControl1.Labels.AddHeader("2D High Low Chart");
   title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic);
   title.TextStyle.FillStyle = new NColorFillStyle(Color.Gray);

   // add a High-Low series
   Random rand = new Random();
   
   NHighLowSeries highLow1 = (NHighLowSeries)chart.Series.Add(SeriesType.HighLow);
   highLow1.Name = "High-Low 1";
   highLow1.HighFillStyle = new NColorFillStyle(Color.Gray);
   highLow1.LowFillStyle = new NColorFillStyle(Color.DarkOrange);
   highLow1.DataLabelStyle.Visible = false;

   highLow1.ClearDataPoints();

    
   for (int i = 0; i < 20; i++)
   {
    double d1 = Math.Log(i + 1) + 0.1 * rand.NextDouble();
    double d2 = d1 + Math.Cos(0.33 * i) + 0.1 * rand.NextDouble();

    highLow1.HighValues.Add(d1);
    highLow1.LowValues.Add(d2);
   }

   // add a High-Low series
   NHighLowSeries highLow2 = (NHighLowSeries)chart.Series.Add(SeriesType.HighLow);
   highLow2.Name = "High-Low 2";
   highLow2.HighFillStyle = new NColorFillStyle(Color.Red);
   highLow2.LowFillStyle = new NColorFillStyle(Color.Green);
   highLow2.DataLabelStyle.Visible = false;

   highLow2.ClearDataPoints();

   for (int i = 0; i < 20; i++)
   {
    double d1 = Math.Log(i + 1) + 0.5 * rand.NextDouble();
    double d2 = d1 + Math.Cos(0.33 * i) + 0.5 * rand.NextDouble();

    highLow2.HighValues.Add(d1);
    highLow2.LowValues.Add(d2);
   }

Generally you can mix an unlimited number of series in a chart.

By Manal Goyal - Thursday, June 14, 2018

Hi,
I see that we can do that, thank you for the example. However I have one more concern that when both of these series occupies same space in chart, one of them would be visible while the other one will be hidden behind. I guess whichever is added first to the chart taked the priority here, Is that true? Is there any other way to assign priority through code?
By Nevron Support - Thursday, June 14, 2018

Hi Manal,
Yes that's right - the paint order is controlled from the position of the series in the chart collection. The first series appears on top of the other series and so on. In order to change the z order of the series you need to change its place in the series collection. We may consider adding a z order property for the series. Let us know if you meet any problems or have any questions.