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


Author
Message
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K
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);
         }
      }


Best Regards,
Nevron Support Team


Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K
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.


Best Regards,
Nevron Support Team


peck 110
peck 110
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)
Group: Forum Members
Posts: 5, Visits: 1

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?


Attachments
question.JPG (57 views, 46.00 KB)
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K

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.



Best Regards,
Nevron Support Team


peck 110
peck 110
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)
Group: Forum Members
Posts: 5, Visits: 1
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 !
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search