Nevron Forum

How to color the area between a line and the vertical axis?

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

By peck 110 - Thursday, July 22, 2010

I want to color the area between a line and the vertical axis.when i use the series type "area",it always color the area between the line and the horizontal axis. there may be easy to meet my need,please help me !
By Nevron Support - Friday, July 23, 2010

Hello,

You can easily achieve this with the following code:

    NChart chart = nChartControl1.Charts[0];
    chart.SetPredefinedChartStyle(
PredefinedChartStyle.HorizontalLeft);

    NAreaSeries area = new NAreaSeries();
    chart.Series.Add(area);
    area.Values.AddRange(
new double[] { 10, 20, 15, 32, 27, 36, 34, 23, 14, 21 });

The series still fills the area between the line and the X axis, but the whole chart is rotated by 90 degrees and the X axis is actually vertical on the screen.

By peck 110 - Monday, July 26, 2010

hello,

Thank you for your reply!

I can't rotate the chart ,because another series needs the vertical axis to be Y axis and the horizontal to be X-axis(please see the attached file), are there any other solutions?

By Nevron Support - Tuesday, July 27, 2010

Hi,

It looks like the other series can be displayed just fine even if the chart is rotated. The real problem is that the control doesn't support step area series, but this can be worked around with an XY-area. Please let us know if you want us to help you with an example for this chart.
By Nevron Support - Thursday, August 5, 2010

Hi,

The following example displays a chart similar to the one that you sent us. If you send us the real data we can modify the example to work with it.


      private void Form1_Load(object sender, EventArgs e)
      {
         NChart chart = nChartControl1.Charts[0];
         chart.SetPredefinedChartStyle(PredefinedChartStyle.HorizontalLeft);
         chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = new NLinearScaleConfigurator();

         // Setup line series
         double[] lineValuesY = new double[] { 35, 32, 30, 30, 31, 34, 39, 43, 47, 47, 46 };
         double[] lineValuesX = new double[] { 15, 17, 21, 22, 24, 27, 27, 27, 25, 23, 20 };

         NLineSeries line = new NLineSeries();
         chart.Series.Add(line);
         line.UseXValues = true;
         line.DataLabelStyle.Visible = false;
         line.MarkerStyle.Visible = true;
         line.MarkerStyle.PointShape = PointShape.Ellipse;
         line.Values.AddRange(lineValuesY);
         line.XValues.AddRange(lineValuesX);

         // Setup area series
         NAreaSeries area = new NAreaSeries();
         chart.Series.Add(area);
         area.UseXValues = true;
         area.DataLabelStyle.Visible = false;

         double[] areaValues = new double[] { 10, 20, 15, 23, 23, 23, 45, 11 };

         for (int i = 0; i < areaValues.Length; i++)
         {
            double value = areaValues[i];
            double xvalue1 = i * 5;
            double xvalue2 = (i + 1) * 5;

            area.Values.Add(value);
            area.XValues.Add(xvalue1);

            area.Values.Add(value);
            area.XValues.Add(xvalue2);
         }
      }