Passing double[] for x and y in windows form


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

By sigfredo santiago - 7 Years Ago
Can you plot double[array] as values for example in a stacked bar graph?

Thanks
By Nevron Support - 7 Years Ago
Hi Sigfredo,

Yes you can import a double array to a stacked bar but it largely depends how the values in the array must be treated. The following code shows how to create a stacked bar chart from a double array where half of the values go into the first bar and the rest into the second:

   NChart chart = nChartControl1.Charts[0];

   double[] values = new double[] { 10, 20, 30, 10, 20, 30 };

   NBarSeries bar1 = new NBarSeries();
   int i = 0;
   for (; i < values.Length / 2; i++)
   {
    bar1.Values.Add(values[i]);
   }
   chart.Series.Add(bar1);

   NBarSeries bar2 = new NBarSeries();
   bar2.MultiBarMode = MultiBarMode.Stacked;
   for (; i < values.Length; i++)
   {
    bar2.Values.Add(values[i]);
   }
   chart.Series.Add(bar2);

Hope this helps - let us know if you have any questions.