Winform the chart control to draw a shaded area

Source: Internet
Author: User

Let's take a look at the effect





Company power projects need to draw this kind of industrial chart, before colleagues with series draw a bit of trouble to calculate the starting point location, later I found that the chart control originally provided this shadow property, simple and convenient


Directly on the code

private void Initchart () {ChartArea chartArea2 = new ChartArea ();            ChartArea2.AxisX.Minimum = 10;            ChartArea2.AxisX.Maximum = 100;            ChartArea2.AxisX.Interval = 10;            ChartArea2.AxisX.IsStartedFromZero = true;            ChartArea2.AxisX.Title = "Primary X axis";            chartArea2.AxisX.Enabled = Axisenabled.true;             ChartArea2.AxisX.TitleAlignment = Stringalignment.near;            ChartArea2.AxisX.MajorGrid.LineColor = Color.brown;            ChartArea2.AxisX.MajorGrid.LineDashStyle = Chartdashstyle.solid;            ChartArea2.AxisY.Minimum = 10;            ChartArea2.AxisY.Maximum = 100;            ChartArea2.AxisY.Interval = 10;            ChartArea2.AxisY.IsStartedFromZero = false;            ChartArea2.AxisY.Title = "Primary Y-axis";            chartArea2.AxisX.Enabled = Axisenabled.true;            Chartarea2.name = "CHARTAREA2";             Series M1 = new series (); M1.            POINTS.ADDXY (0, 100);M1.            POINTS.ADDXY (85, 100); M1.            ChartType = Seriescharttype.area; M1.            Color = color.red; M1.            Backhatchstyle = charthatchstyle.darkdownwarddiagonal;            Series m2 = new series (); M2.            POINTS.ADDXY (10, 30); M2.            POINTS.ADDXY (35, 55); M2.            POINTS.ADDXY (65, 55); M2.            POINTS.ADDXY (85, 65); M2.            ChartType = Seriescharttype.line; M2.              Color = Color.Blue; M2.             BorderWidth = 2;            Series M5 = new series (); M5.            POINTS.ADDXY (10, 30); M5.            POINTS.ADDXY (35, 55); M5.            POINTS.ADDXY (65, 55); M5.            POINTS.ADDXY (85, 65); M5.            ChartType = Seriescharttype.area; M5.            Color = Color.purple; M5.            Backhatchstyle = charthatchstyle.darkdownwarddiagonal;            Series M6 = new series (); M6.            POINTS.ADDXY (10, 20); M6.            POINTS.ADDXY (35, 45); M6.            POINTS.ADDXY (65, 45); M6.            POINTS.ADDXY (85, 55); M6.ChartType = Seriescharttype.line; M6.            Color = Color.Blue; M6.             BorderWidth = 2;            Series M3 = new series (); M3.            POINTS.ADDXY (10, 20); M3.            POINTS.ADDXY (35, 45); M3.            POINTS.ADDXY (65, 45); M3.            POINTS.ADDXY (85, 55); M3.            ChartType = Seriescharttype.area; M3.            Color = Color.green; M3.                        Backhatchstyle = charthatchstyle.darkdownwarddiagonal;            THIS.CHART1.SERIES.ADD (M1);             This.chart1.Series.Add (m2);            THIS.CHART1.SERIES.ADD (M5);             THIS.CHART1.SERIES.ADD (M6);                         This.chart1.Series.Add (m3);         THIS.CHART1.CHARTAREAS.ADD (CHARTAREA2); }



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Winform the chart control to draw a shaded area

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.