ASP.NET数据控件之Chart的用法
多加一嘴:
如若想使得网站后退按钮,可以考虑使用HiddenField存放Uri,可以加密,也可以通过this.Request.UrlReferrer获取得到URL 注意获取this.Request.UrlReferrer返回值为URI类型
直接上代码:
前台页面写法
1 <asp:Chart ID="ChartPie" runat="server" Width="950px" BackColor="#FFFFCC" Palette="BrightPastel"
2 BorderWidth="0" BorderColor="#cc9900">
3 <Annotations></Annotations>
4 <Legends>
5 <asp:Legend IsTextAutoFit="False" Name="Default" BackColor="Transparent" Font="Trebuchet MS, 8.25pt, style=Bold">
6 </asp:Legend>
7 </Legends>
8 <ChartAreas>
9 <asp:ChartArea Name="ChartArea1">
10 </asp:ChartArea>
11 </ChartAreas>
12 </asp:Chart>
后台:表结构如下s
后台需要的表结构
1 table = new DataTable();
2 table.Columns.AddRange(new DataColumn[]{
3 new DataColumn("url",typeof(String)),
4 new DataColumn("liulan",typeof(Int32)),
5 new DataColumn("易做图",typeof(Int32)),
6 new DataColumn("dacpno",typeof(Int32))
7 });
Bind方式如下:
后台邦定
1 Series seriesPies = new Series("受访域名统计");
2 this.ChartPie.Series.Add(seriesPies);
3 this.ChartPie.ChartAreas[0].Area3DStyle.Enable3D = true;
4 seriesPies.ChartType = SeriesChartType.Pie;
5 seriesPies.BorderWidth = 3;
6 seriesPies.ShadowOffset = 2;
7 Title tPie = new Title("受访域名统计饼状图", Docking.Top, new Font(FontFamily.GenericSerif, 16, FontStyle.Bold), Color.Brown);
8 tPie.ShadowColor = Color.Gray;
9 tPie.ShadowOffset = 2;
10 this.ChartPie.Titles.Add(tPie);
11
12 for (int i = 0; i < this.table.Rows.Count; i++)
13 {
14 object count = this.table.Rows[i]["liulan"];
15 seriesPies.CustomProperties = "PieLabelStyle=Outside";//让饼状图的图示区域和图示文本用线连接
16 seriesPies.Points.AddXY(string.Concat(this.table.Rows[i]["url"], "(", count, ")"), count);
17
摘自 天下
补充:Web开发 , ASP.Net ,