工作中点滴记录

永远保持学徒心态

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

View Code
 1    protected void Page_Load(object sender, EventArgs e)
 2         {
 3             if (!IsPostBack)
 4             {
 5                 int[] date = new int[] { 20, 40, 50, 80, 30, 10, 60 };
 6                 int[] test = new int[] { 10, 80, 70, 40, 20, 50, 90 };
 7                 Chart1.Width = 600;
 8                 Chart1.Height = 400;
 9                 Chart1.BackColor = Color.Azure;
10                 //设置第一个图表集合
11                 Series series = new Series("test");
12                 //设置图表类型
13                 series.ChartType = SeriesChartType.Column;
14                 //设置图表数据点的宽度
15                 series.BorderWidth = 1;
16                 //设置图表阴影偏移量
17                 series.ShadowOffset = 8;
18                 //设置数据点颜色
19                 series.Color = Color.Red;
20                 //指示是否在标签上显示数据点的值
21                 series.IsValueShownAsLabel = false;
22                 //指示是否显示图例 
23                 series.IsVisibleInLegend = true;
24                 //设置标记样式 
25                 series.MarkerStyle = MarkerStyle.Diamond;
26                 //设置标记大小
27                 series.MarkerSize = 3;
28                 //设置标记颜色
29                 series.MarkerColor = Color.Red;
30                 DateTime date1 = DateTime.Now.Date;
31                 for (int i = 0; i < date.Length; i++)
32                 {
33                     series.Points.AddXY(date1, date[i]);
34                     series.ToolTip = "日期:\t#VALX\n数值:\t#VALY";
35                     date1 = date1.AddDays(1);
36                 }
37                 Chart1.Series.Add(series);
38                 //创建第二个图标集合
39                 Series series1 = new Series();
40                 series1.ChartType = SeriesChartType.Column;
41                 series1.BorderWidth = 1;
42                 series1.Color = Color.Green;
43                 series1.ShadowOffset = 1;
44                 series1.IsValueShownAsLabel = false;
45                 series1.IsVisibleInLegend = true;
46                 series1.MarkerStyle = MarkerStyle.Square;
47                 series1.MarkerSize = 3;
48                 series1.MarkerColor = Color.Black;
49                 date1 = DateTime.Now.Date;
50                 for (int i = 0; i < test.Length; i++)
51                 {
52                     series1.Points.AddXY(date1, test[i]);
53                     date1 = date1.AddDays(1);
54                     series1.ToolTip = "日期:\t#VALX\n数值:\t#VALY";
55                 }
56                 Chart1.Series.Add(series1);
57                 //设置X轴与Y轴的轴线颜色
58                 this.Chart1.ChartAreas[0].AxisX.LineColor = Color.Blue;
59                 this.Chart1.ChartAreas[0].AxisY.LineColor = Color.Blue;
60                 //设置X轴与Y轴的轴线宽度
61                 this.Chart1.ChartAreas[0].AxisY.LineWidth = 2;
62                 this.Chart1.ChartAreas[0].AxisX.LineWidth = 2;
63                 //设置X轴与Y轴的标题
64                 this.Chart1.ChartAreas[0].AxisX.Title = "日期";
65                 this.Chart1.ChartAreas[0].AxisY.Title = "数据";
66                 //设置X轴与Y轴的网格线
67                 this.Chart1.ChartAreas[0].AxisY.MajorGrid.LineColor = Color.Blue;
68                 this.Chart1.ChartAreas[0].AxisX.MajorGrid.LineColor = Color.Gray;
69             }
70         }

后面继续添加中 !!!

posted on 2012-10-16 23:29  梦里故乡  阅读(335)  评论(0编辑  收藏  举报