VBA 画好看的饼图

MS Chart Control �W�手�(二) - �A��D

2011/10/24 17:57 | ��x�� : 7333 | 我要推�] | 5 Comments | 文章分� : ASP.NET C# MSChart | ��
�^上一篇的直�l�D
�@次要�P�的是�A��D(Pie)
01 usingSystem.Web.UI.DataVisualization.Charting;
02 usingSystem.Drawing;
03
04 namespaceChart.AJAX
05 {
06 publicpartialclassExport_AJAX : System.Web.UI.Page
07 {
08 voidCreateChart()
09 {
10 string[] xValues = { "0-20", "20-30", "30-40", "40-50", "50-60", "> 60", "unknow"};
11 int[] yValues = {5, 18, 45, 17, 2, 1, 162 };
12
13 //ChartAreas,Series,Legends 基本�O定-------------------------------------------------
14 Chart Chart1 = newChart();
15 Chart1.ChartAreas.Add("ChartArea1"); //�D表�^域集合
16 Chart1.Legends.Add("Legends1"); //�D例集合�f明
17 Chart1.Series.Add("Series1"); //���序列集合
18
19 //�O定 Chart-------------------------------------------------------------------------
20 Chart1.Width = 770;
21 Chart1.Height = 400;
22 Title title = newTitle();
23 title.Text = titleStr;
24 title.Alignment = ContentAlignment.MiddleCenter;
25 title.Font = newSystem.Drawing.Font("Trebuchet MS", 14F, FontStyle.Bold);
26 Chart1.Titles.Add(title);
27
28 //�O定 ChartArea1--------------------------------------------------------------------
29 Chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = is3D;
30 Chart1.ChartAreas[0].AxisX.Interval = 1;
31
32 //�O定 Legends-------------------------------------------------------------------------              
33 //Chart1.Legends["Legends1"].DockedToChartArea = "ChartArea1"; //�@示在�D表��
34 //Chart1.Legends["Legends1"].Docking = Docking.Bottom; //自��@示位置
35 //背景色
36 Chart1.Legends["Legends1"].BackColor = Color.FromArgb(235, 235, 235);
37 //斜�背景
38 Chart1.Legends["Legends1"].BackHatchStyle = ChartHatchStyle.DarkDownwardDiagonal;
39 Chart1.Legends["Legends1"].BorderWidth = 1;
40 Chart1.Legends["Legends1"].BorderColor = Color.FromArgb(200, 200, 200);
41
42 //�O定 Series1-----------------------------------------------------------------------
43 Chart1.Series["Series1"].ChartType = SeriesChartType.Pie;
44 //Chart1.Series["Series1"].ChartType = SeriesChartType.Doughnut;
45 Chart1.Series["Series1"].Points.DataBindXY(xValues, yValues);
46 Chart1.Series["Series1"].LegendText = "#VALX:    [ #PERCENT{P1} ]"; //X�S + 百分比
47 Chart1.Series["Series1"].Label = "#VALX\n#PERCENT{P1}"; //X�S + 百分比
48 //Chart1.Series["Series1"].LabelForeColor = Color.FromArgb(0, 90, 255); //字�w�色
49 //字�w�O定
50 Chart1.Series["Series1"].Font = newSystem.Drawing.Font("Trebuchet MS", 10, System.Drawing.FontStyle.Bold);
51 Chart1.Series["Series1"].Points.FindMaxByValue().LabelForeColor = Color.Red;
52 //Chart1.Series["Series1"].Points.FindMaxByValue().Color = Color.Red;
53 //Chart1.Series["Series1"].Points.FindMaxByValue()["Exploded"] = "true";
54 Chart1.Series["Series1"].BorderColor = Color.FromArgb(255, 101, 101, 101);
55
56 //Chart1.Series["Series1"]["DoughnutRadius"] = "80"; // ChartType��Doughnut�r,Set Doughnut hole size
57 //Chart1.Series["Series1"]["PieLabelStyle"] = "Inside"; //�抵碉@示在�A���
58 Chart1.Series["Series1"]["PieLabelStyle"] = "Outside"; //�抵碉@示在�A�外
59 //Chart1.Series["Series1"]["PieLabelStyle"] = "Disabled"; //不�@示�抵�
60 //�O定�A�效果,除 Default 外其他效果3D不�m用
61 Chart1.Series["Series1"]["PieDrawingStyle"] = "Default";
62 //Chart1.Series["Series1"]["PieDrawingStyle"] = "SoftEdge";
63 //Chart1.Series["Series1"]["PieDrawingStyle"] = "Concave";
64
65 //Random rnd = new Random();  //�y�诞a生�^�K�色
66 //foreach (DataPoint point in Chart1.Series["Series1"].Points)
67 //{
68 //    //pie �色
69 //    point.Color = Color.FromArgb(150, rnd.Next(0, 255), rnd.Next(0, 255), rnd.Next(0, 255));
70 //}
71 Page.Controls.Add(Chart1);
72 }
73 }
74 }


��出�淼�A��D就像�@��


你可能感兴趣的:(VBA,饼图)