报表统计(六) 访问数据库

2D

代码:

View Code
 1  protected void Page_Load(object sender, EventArgs e)
 2         {
 3             if (!IsPostBack)
 4             {
 5                 string[] names = new string[] { "A", "B", "C" };
 6                 int[] data = new int[] { 100, 400, 100 };
 7                 int[] data1 = new int[] { 200, 800, 200 };
 8                 int[] data2 = new int[] { 300, 600, 300 };
 9 
10                 Chart1.Width = 600;
11                 Chart1.Height = 400;
12                 Chart1.ChartAreas[0].AxisX.Title = "销售人员";
13                 Chart1.ChartAreas[0].AxisY.Title = "营业收入";
14                 Chart1.ChartAreas[0].AxisX.LineColor = Color.Red;
15                 Chart1.ChartAreas[0].AxisX.LineWidth = 2;
16                 Chart1.ChartAreas[0].AxisX.MajorGrid.LineColor = Color.Gray;
17                 Chart1.ChartAreas[0].BackColor = Color.Azure;
18                 Chart1.ChartAreas[0].AxisY.LineColor = Color.Green;
19                 Chart1.ChartAreas[0].AxisY.LineWidth = 2;
20                 Chart1.Titles.Add("销售人员销售记录");
21                 Series s1 = new Series();
22                 s1.ChartType = SeriesChartType.Line;
23                 s1.Color = Color.Red;
24                 s1.IsValueShownAsLabel = true;
25                 s1.IsVisibleInLegend = true;
26                 s1.MarkerSize = 8;
27                 s1.MarkerStyle = MarkerStyle.Circle;
28                 Chart1.Series.Add(s1);
29 
30                 Series s2 = new Series();
31                 s2.ChartType = SeriesChartType.Line;
32                 s2.Color = Color.Yellow;
33                 s2.IsValueShownAsLabel = true;
34                 s2.IsVisibleInLegend = true;
35                 s2.MarkerSize = 8;
36                 s2.MarkerStyle = MarkerStyle.Cross;
37                 Chart1.Series.Add(s2);
38 
39                 Series s3 = new Series();
40                 s3.ChartType = SeriesChartType.Line;
41                 s3.Color = Color.Green;
42                 s3.IsValueShownAsLabel = true;
43                 s3.IsVisibleInLegend = true;
44                 s3.MarkerSize = 8;
45                 s3.MarkerStyle = MarkerStyle.Diamond;
46                 Chart1.Series.Add(s3);
47                 Chart1.Series[0].ToolTip = "销售人员:\t#VALX\n销售额:\t#VALY";
48                 Chart1.Series[1].ToolTip = "销售人员:\t#VALX\n销售额:\t#VALY";
49                 Chart1.Series[2].ToolTip = "销售人员:\t#VALX\n销售额:\t#VALY";
50                 for (int i = 0; i < names.Length; i++)
51                 {
52                     Chart1.Series[0].Points.AddXY(names[i], data[i]);
53                     Chart1.Series[1].Points.AddXY(names[i], data1[i]);
54                     Chart1.Series[2].Points.AddXY(names[i], data2[i]);
55                 }
56                 //Chart1.ChartAreas[0].Area3DStyle.Enable3D = true;
57 
58             }
59         }

3D

代码

View Code
 1  protected void Page_Load(object sender, EventArgs e)
 2         {
 3             if (!IsPostBack)
 4             {
 5                 string[] names = new string[] { "A", "B", "C" };
 6                 int[] data = new int[] { 100, 400, 100 };
 7                 int[] data1 = new int[] { 200, 800, 200 };
 8                 int[] data2 = new int[] { 300, 600, 300 };
 9 
10                 Chart1.Width = 600;
11                 Chart1.Height = 400;
12                 Chart1.ChartAreas[0].AxisX.Title = "销售人员";
13                 Chart1.ChartAreas[0].AxisY.Title = "营业收入";
14                 Chart1.ChartAreas[0].AxisX.LineColor = Color.Red;
15                 Chart1.ChartAreas[0].AxisX.LineWidth = 2;
16                 Chart1.ChartAreas[0].AxisX.MajorGrid.LineColor = Color.Gray;
17                 Chart1.ChartAreas[0].BackColor = Color.Azure;
18                 Chart1.ChartAreas[0].AxisY.LineColor = Color.Green;
19                 Chart1.ChartAreas[0].AxisY.LineWidth = 2;
20                 Chart1.Titles.Add("销售人员销售记录");
21                 Series s1 = new Series();
22                 s1.ChartType = SeriesChartType.Line;
23                 s1.Color = Color.Red;
24                 s1.IsValueShownAsLabel = true;
25                 s1.IsVisibleInLegend = true;
26                 s1.MarkerSize = 8;
27                 s1.MarkerStyle = MarkerStyle.Circle;
28                 Chart1.Series.Add(s1);
29 
30                 Series s2 = new Series();
31                 s2.ChartType = SeriesChartType.Line;
32                 s2.Color = Color.Yellow;
33                 s2.IsValueShownAsLabel = true;
34                 s2.IsVisibleInLegend = true;
35                 s2.MarkerSize = 8;
36                 s2.MarkerStyle = MarkerStyle.Cross;
37                 Chart1.Series.Add(s2);
38 
39                 Series s3 = new Series();
40                 s3.ChartType = SeriesChartType.Line;
41                 s3.Color = Color.Green;
42                 s3.IsValueShownAsLabel = true;
43                 s3.IsVisibleInLegend = true;
44                 s3.MarkerSize = 8;
45                 s3.MarkerStyle = MarkerStyle.Diamond;
46                 Chart1.Series.Add(s3);
47                 Chart1.Series[0].ToolTip = "销售人员:\t#VALX\n销售额:\t#VALY";
48                 Chart1.Series[1].ToolTip = "销售人员:\t#VALX\n销售额:\t#VALY";
49                 Chart1.Series[2].ToolTip = "销售人员:\t#VALX\n销售额:\t#VALY";
50                 for (int i = 0; i < names.Length; i++)
51                 {
52                     Chart1.Series[0].Points.AddXY(names[i], data[i]);
53                     Chart1.Series[1].Points.AddXY(names[i], data1[i]);
54                     Chart1.Series[2].Points.AddXY(names[i], data2[i]);
55                 }
56                 Chart1.ChartAreas[0].Area3DStyle.Enable3D = true;
57 
58             }
59         }
怀揣着一点点梦想的年轻人
相信技术和创新的力量
喜欢快速反应的工作节奏
原文地址:https://www.cnblogs.com/hfliyi/p/2728251.html