//前台代码 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="bing.aspx.cs" Inherits="bing" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <%@ Register TagPrefix="Web" Namespace="WebChart" Assembly="WebChart" %><!--这句必须有 --> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>无标题页</title> </head> <body> <form id="form1" runat="server"> <Web:ChartControl id="chart1" runat="server" TopPadding="20" HasChartLegend="False" ShowXValues="False" GridLines="None" ShowYValues="False" Width="580px" Height="436px"> <Border StartCap="Flat" EndCap="Flat" Width="0" DashStyle="Solid" Color="Black" LineJoin="Miter"></Border> <XAxisFont ForeColor="Black" Font="Tahoma, 8pt"></XAxisFont> <PlotBackground Type="Solid" StartPoint="0, 0" ForeColor="Black" EndPoint="100, 100" Color="White" HatchStyle="Shingle"></PlotBackground> <ChartTitle ForeColor="BlanchedAlmond" Text="My First Pie" Font="Tahoma, 12pt, style="Bold" mce_style="Bold""></ChartTitle> <Legend Width="100" Font="Tahoma, 6pt"> <Border StartCap="Flat" EndCap="Flat" Width="0" DashStyle="Solid" Color="Black" LineJoin="Miter"></Border> <Background Type="Solid" StartPoint="0, 0" ForeColor="Black" EndPoint="100, 100" Color="White" HatchStyle="Shingle"></Background> </Legend> <XTitle ForeColor="Black" Font="Tahoma, 8pt"></XTitle> <Background Type="Solid" StartPoint="0, 0" ForeColor="Black" EndPoint="100, 100" Color="LightSteelBlue" HatchStyle="Shingle"></Background> <YTitle ForeColor="Black" Font="Tahoma, 8pt"></YTitle> </Web:ChartControl> </form> </body> </html> //后台代码 using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Drawing; using WebChart; public partial class bing : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { ChartPointCollection data = new ChartPointCollection(); data.Add(new ChartPoint("Ene", 10)); data.Add(new ChartPoint("Feb", 20)); data.Add(new ChartPoint("Mar", 30)); data.Add(new ChartPoint("Abr", 30)); data.Add(new ChartPoint("May", 10)); data.Add(new ChartPoint("Jun", 25)); PieChart c = new PieChart(data, Color.Blue); c.Colors = new Color[] { Color.Red, Color.Blue, Color.Yellow, Color.Cyan, Color.AntiqueWhite, Color.RosyBrown }; chart1.Charts.Add(c); chart1.RedrawChart(); } } #region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); } /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); } #endregion }