Chart Chart1 = new Chart();
Chart1.Width = 612;
Chart1.Height = 296;
Chart1.RenderType = RenderType.ImageTag;
Chart1.Palette = ChartColorPalette.SemiTransparent;
Title t = new Title("No Code Behind Page", Docking.Top, new System.Drawing.Font("宋体", 14, System.Drawing.FontStyle.Strikeout), System.Drawing.Color.FromArgb(Convert.ToInt32("00", 16), Convert.ToInt32("FF", 16), Convert.ToInt32("00", 16)));
Chart1.Titles.Add(t);
Chart1.ChartAreas.Add("Areas 1");
// Show as 3D
Chart1.ChartAreas["Areas 1"].Area3DStyle.Enable3D = false;
// Enable X axis labels automatic fitting
Chart1.ChartAreas["Areas 1"].AxisX.IsLabelAutoFit = true;
Chart1.ChartAreas["Areas 1"].AxisY.LabelStyle.Format = "{0:C}";
// Set X axis automatic fitting style
Chart1.ChartAreas["Areas 1"].AxisX.LabelAutoFitStyle =
LabelAutoFitStyles.DecreaseFont | LabelAutoFitStyles.IncreaseFont | LabelAutoFitStyles.WordWrap;
// create a couple of series
//Chart1.Series.Add("Series 1");
//Chart1.Series["Series 1"].ChartType = SeriesChartType.Column;
//Chart1.Series["Series 1"].ChartArea = "Areas 1";
//Chart1.Series["Series 1"].IsValueShownAsLabel = true;
//Chart1.Series["Series 1"].LabelFormat = "{0:C}";
//// Draw as 3D Cylinder
//Chart1.Series["Series 1"]["DrawingStyle"] = "Cylinder";
//Chart1.Series.Add("Series 2");
//Chart1.Series["Series 2"].ChartType = SeriesChartType.Line;
//Chart1.Series["Series 2"].ChartArea = "Areas 1";
DataTable dt = new DataTable();
dt.Columns.Add("name");
dt.Columns.Add("数学", typeof(int));
dt.Columns.Add("语文", typeof(int));
dt.Rows.Add(new object[] { "jiashiyi", 100, 150 });
dt.Rows.Add(new object[] { "jiazichen", 150, 100 });
Chart1.DataBindTable(dt.DefaultView, "name");
Chart1.Series["数学"].ChartType = SeriesChartType.Line;
//Chart1.Series["Series 1"].Points.DataBindY(myReader, "GrossSales");
// add points to series 1
//Chart1.Series["Series 1"].Points.AddY(5);
//Chart1.Series["Series 1"].Points.AddY(8);
//Chart1.Series["Series 1"].Points.AddY(12);
//Chart1.Series["Series 1"].Points.AddY(6);
//Chart1.Series["Series 1"].Points.AddY(9);
//Chart1.Series["Series 1"].Points.AddY(4);
//Chart1.Series["Series 1"].Points[0].AxisLabel = "jiashiyi";
////Chart1.Series["Series 1"].Points[0].Label = "jiashiyi";
//// add points to series 2
//Chart1.Series["Series 2"].Points.AddY(2);
//Chart1.Series["Series 2"].Points.AddY(6);
//Chart1.Series["Series 2"].Points.AddY(18);
//Chart1.Series["Series 2"].Points.AddY(16);
//Chart1.Series["Series 2"].Points.AddY(21);
//Chart1.Series["Series 2"].Points.AddY(14);
Chart1.BorderSkin.SkinStyle = BorderSkinStyle.Emboss;
Chart1.BorderColor = System.Drawing.Color.FromArgb(26, 59, 105);
Chart1.BorderlineDashStyle = ChartDashStyle.Solid;
Chart1.BorderWidth = 2;
Chart1.Legends.Add("Legend1");
//Chart1.Series["Series 1"].Legend = "Legend1";
// show legend based on check box value
Chart1.Legends["Legend1"].Enabled = true;
Chart1.Page = Page;
ph.Controls.Add(Chart1);