Profile Picture

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

Posted By peck 110 14 Years Ago

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

Author
Message
Nevron Support
Posted 14 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009
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
Posted 14 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009
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
Posted 14 Years Ago
View Quick Profile
Forum Newbie

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
Last Active: 11 Years Ago
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 (46 views, 46.00 KB)
Nevron Support
Posted 14 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009

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
sad Posted 14 Years Ago
View Quick Profile
Forum Newbie

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
Last Active: 11 Years Ago
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 !



Similar Topics


Reading This Topic