Line and column drawing methods in MSChart drawing controls

Source: Internet
Author: User

First drag a MSChart control named Chart1 into the foreground

          
Line chart
stringStrlegend ="Legend1"; Legend LG=NewLegend (strlegend); Lg. Isdockedinsidechartarea=false; Lg. Titlealignment=System.Drawing. Stringalignment.center; Chart1. Legends.add (LG); ChartArea CA=NewChartArea (); Ca. AxisX.MajorGrid.Enabled=false; Ca. AxisX.MajorTickMark.Enabled=false; Ca. AxisY.MajorGrid.LineDashStyle=Chartdashstyle.notset; intindex =1; Series Myscore=NewSeries ("my score." ); Myscore.charttype=Seriescharttype.line; Myscore.legend="Legend1"; Myscore.chartarea="ChartArea1"; Myscore.borderwidth= +; Series Highscore=NewSeries ("Highest score" ); Highscore.charttype=Seriescharttype.line; Highscore.legend="Legend1"; Highscore.chartarea="ChartArea1"; Myscore.borderwidth= +; Series Avgscore=NewSeries ("Average score" ); Avgscore.charttype=Seriescharttype.line; Avgscore.legend="Legend1"; Avgscore.chartarea="ChartArea1"; Myscore.borderwidth= +; foreach(DataRow Drinchm_table. Rows) {Datapoint dp; if(dr["Myscore"] ==NULL) Continue; DP=NewDatapoint (Index, convert.todouble (dr["Myscore" ])); Dp. AxisLabel= dr["Name"]. ToString (); Dp. Label= Convert.ToInt32 (dr["Myscore" ]). ToString (); Dp. BorderWidth=Ten; Dp. MarkerStyle=System.Windows.Forms.DataVisualization.Charting.MarkerStyle. Star10; MYSCORE.POINTS.ADD (DP); DP=NewDatapoint (Index, convert.todouble (dr["Highscore" ])); Dp. AxisLabel= dr["Name"]. ToString (); Dp. Label= Convert.ToInt32 (dr["Highscore" ]). ToString (); Dp. BorderWidth=Ten; Dp. MarkerStyle=System.Windows.Forms.DataVisualization.Charting.MarkerStyle. Star10; HIGHSCORE.POINTS.ADD (DP); DP=NewDatapoint (Index, convert.todouble (dr["Avgscore" ])); Dp. AxisLabel= dr["Name"]. ToString (); Dp. Label= Convert.ToInt32 (dr["Avgscore" ]). ToString (); Dp. BorderWidth=Ten; Dp. MarkerStyle=System.Windows.Forms.DataVisualization.Charting.MarkerStyle. Star10; AVGSCORE.POINTS.ADD (DP); Index++; } Chart1. Series.add (Myscore); Chart1. Series.add (Highscore); Chart1. Series.add (Avgscore); Chart1. Chartareas.add (CA);
         
Column Chart
StringStrlegend ="Legend1" ; Legend LG=NewLegend (strlegend); Lg. Isdockedinsidechartarea=false; Lg. Titlealignment=System.Drawing.StringAlignment. Center; Chart1. Legends.add (LG); ChartArea CA=NewChartArea (); Ca. AxisX.MajorGrid.Enabled=false; Ca. AxisX.MajorTickMark.Enabled=false; Ca. AxisY.MajorGrid.LineDashStyle=Chartdashstyle.notset; intindex =1; foreach(DataRow Drinchdt. Rows) {Series s=NewSeries (dr["Coursetermname" ]. ToString ()); S.charttype=Seriescharttype.column; S.legend="Legend1"; S.chartarea="ChartArea1"; Datapoint DP; DP=NewDatapoint (Index, convert.todouble (dr["score" ])); Dp. AxisLabel= dr["Coursetermname"]. ToString (); Dp. Label= Convert.ToInt32 (dr["score" ]). ToString (); Dp. MarkerStyle=System.Windows.Forms.DataVisualization.Charting.MarkerStyle. Star10; S.points.add (DP); Chart1. Series.add (s); Index++; } Chart1. Chartareas.add (CA);
Setting the borderwidth of a sequence can change the thickness of the line, which is an int value, the larger the value, the thicker the line;

Setting the MarkerStyle of a sequence can show a data point marker, which is an enumeration, with multiple styles, dots, triangles, rectangles, and even a shape that can be specified as a data point by markerimage, and attributes can be Markersize and Markerborderwidth to specify the data point size, Markercolor and Markerbordercolor to specify the data point color.

Hope to be of help to everyone. These are all I've done in the project.

Line and column drawing methods in MSChart drawing controls

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.