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