画图就使用第三方控件WebChart
废话不多说上代码,Chart1是你的控件ID,效果图也附上了:
private void Page_Load(object sender, System.EventArgs e) {
if (Page.IsPostBack==false) {
#region FILLDATA
ChartPointCollection data = new ChartPointCollection();
data.Add(new ChartPoint("Jan",20));
data.Add(new ChartPoint("Feb",40));
data.Add(new ChartPoint("Mar",20));
data.Add(new ChartPoint("Apr",30));
data.Add(new ChartPoint("May",30));
data.Add(new ChartPoint("Jun",0));
data.Add(new ChartPoint("Jul",50));
data.Add(new ChartPoint("Aug",10));
data.Add(new ChartPoint("Sep",90));
data.Add(new ChartPoint("Oct",20));
data.Add(new ChartPoint("Nov",50));
data.Add(new ChartPoint("Dec",60));
#endregion
Chart cl = new SmoothLineChart(data, Color.Black );
cl.Legend = "User A";
cl.Fill.Color = Color.Maroon ;
cl.LineMarker = new CircleLineMarker(6, cl.Fill.Color, cl.Line.Color);
Chart1.Charts.Add(cl);
ChartPointCollection data2;
#region FILLDATA
data2 = new ChartPointCollection();
data2.Add(new ChartPoint("Jan",20));
data2.Add(new ChartPoint("Feb",25));
data2.Add(new ChartPoint("Mar",40));
data2.Add(new ChartPoint("Apr",10));
data2.Add(new ChartPoint("May",30));
data2.Add(new ChartPoint("Jun",10));
data2.Add(new ChartPoint("Jul",30));
data2.Add(new ChartPoint("Aug",20));
data2.Add(new ChartPoint("Sep",44));
data2.Add(new ChartPoint("Oct",33));
data2.Add(new ChartPoint("Nov",13));
data2.Add(new ChartPoint("Dec",26));
#endregion
Chart c2 = new SmoothLineChart(data2, Color.Black);
c2.Legend ="User B";
c2.Fill.Color = Color.Crimson;
c2.LineMarker = new SquareLineMarker(6, c2.Fill.Color, c2.Line.Color);
Chart1.Charts.Add(c2);
Chart c3 = new SmoothLineChart();
#region Chart4
data2 = new ChartPointCollection();
data2.Add(new ChartPoint("Jan",20));
data2.Add(new ChartPoint("Feb",40));
data2.Add(new ChartPoint("Mar",40));
data2.Add(new ChartPoint("Apr",60));
data2.Add(new ChartPoint("May",10));
data2.Add(new ChartPoint("Jun",7));
data2.Add(new ChartPoint("Jul",15));
data2.Add(new ChartPoint("Aug",23));
data2.Add(new ChartPoint("Sep",0));
data2.Add(new ChartPoint("Oct",25));
data2.Add(new ChartPoint("Nov",1));
data2.Add(new ChartPoint("Dec",30));
c3 = new SmoothLineChart(data2);
c3.Legend ="User D";
c3.Fill.Color = Color.Red;
c3.Fill.ForeColor= Color.Blue;
c3.Fill.CenterColor = Color.Black;
c3.LineMarker = new XLineMarker(6, c3.Fill.Color, c3.Line.Color);
Chart1.Charts.Add(c3);
#endregion
data2 = new ChartPointCollection();
data2.Add(new ChartPoint("Jan",10));
data2.Add(new ChartPoint("Feb",24));
data2.Add(new ChartPoint("Mar",18));
data2.Add(new ChartPoint("Apr",22));
data2.Add(new ChartPoint("May",11));
data2.Add(new ChartPoint("Jun",19));
data2.Add(new ChartPoint("Jul",21));
data2.Add(new ChartPoint("Aug",20));
data2.Add(new ChartPoint("Sep",14));
data2.Add(new ChartPoint("Oct",34));
data2.Add(new ChartPoint("Nov",12));
data2.Add(new ChartPoint("Dec",20));
c3 = new SmoothLineChart(data2);
c3.Legend ="User D";
c3.Fill.Color = Color.SaddleBrown;
c3.Fill.ForeColor= Color.Blue;
c3.LineMarker = new DiamondLineMarker(6,Color.Transparent, c3.Line.Color);
Chart1.Charts.Add(c3);
data2 = new ChartPointCollection();
c3 = new SmoothLineChart(new ChartPointCollection(
new ChartPoint[]{
new ChartPoint("Jan",10),
new ChartPoint("Feb",0) ,
new ChartPoint("Mar",20),
new ChartPoint("Apr",70),
new ChartPoint("May",20),
new ChartPoint("Jun",32),
new ChartPoint("Jul",25),
new ChartPoint("Aug",29),
new ChartPoint("Sep",12),
new ChartPoint("Oct",17),
new ChartPoint("Nov",18),
new ChartPoint("Dec",1 )
}
));
c3.Legend ="User E";
c3.Fill.Color = Color.Brown;
c3.Fill.ForeColor= Color.Blue;
c3.Fill.CenterColor = Color.Black;
c3.LineMarker = new TriangleLineMarker(6, c3.Fill.Color, c3.Line.Color);
Chart1.Charts.Add(c3);
Chart1.XAxisFont.StringFormat.Alignment=StringAlignment.Center;
Chart1.XAxisFont.Font = new Font("Tahoma",8);
Chart1.XTitle.Text = "Month";
Chart1.XTitle.Font = new Font("Tahoma", 12, FontStyle.Bold);
Chart1.XTitle.ForeColor = Color.Blue;
Chart1.YTitle.Text = "Bugs";
Chart1.YTitle.Font = new Font("Tahoma", 12, FontStyle.Bold);
Chart1.YTitle.ForeColor = Color.Black;
Chart1.YTitle.StringFormat.FormatFlags = StringFormatFlags.DirectionVertical;
ChartText txt = new ChartText();
txt.Font = new Font("Courier New", 14, FontStyle.Bold | FontStyle.Italic);
txt.Text="Testing";
Chart1.ChartTitle = txt;
Chart1.RedrawChart();
}
}