首页 > 编程 > .NET > 正文

asp.net微软图表控件使用示例代码分享

2024-07-10 13:18:15
字体:
来源:转载
供稿:网友

复制代码 代码如下:


<configuration>
  <system.webServer>
    <handlers>
      <remove />
      <add preCondition="integratedMode" verb="GET,HEAD,POST"
        path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </handlers>
  </system.webServer>
  <system.web>
    <httpHandlers>
      <add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        validate="false" />
    </httpHandlers>
  </system.web>
</configuration>

复制代码 代码如下:


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="chart.aspx.cs" Inherits="chart" %>

<%@ Register Assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>MsChart图表控件</title>
</head>
<body>
    <form runat="server">
    <div>
        <asp:Chart runat="server" BorderDashStyle="Solid" Palette="BrightPastel" imagetype="Png"  BackSecondaryColor="White" BackGradientStyle="TopBottom" BorderWidth="2" backcolor="#D3DFF0" BorderColor="26, 59, 105">
            <Titles>
                <asp:Title Font="微软雅黑, 16pt" Text="统计表">
                </asp:Title>
            </Titles>
            <borderskin skinstyle="Emboss"></borderskin>
            <Series>
                <asp:Series  ChartType="Bubble" MarkerSize="8" MarkerStyle="Circle">
                </asp:Series>
            </Series>
            <ChartAreas>
                <asp:ChartArea  BorderColor="64, 64, 64, 64" BackSecondaryColor="Transparent" BackColor="64, 165, 191, 228" ShadowColor="Transparent" BackGradientStyle="TopBottom">
                </asp:ChartArea>
            </ChartAreas>
        </asp:Chart> 

        <asp:Chart runat="server">
            <Series>
                <asp:Series>
                </asp:Series>
            </Series>
            <ChartAreas>
                <asp:ChartArea>
                </asp:ChartArea>
            </ChartAreas>
        </asp:Chart>
        <br/>

        <asp:Chart runat="server">
            <Series>
                <asp:Series>
                </asp:Series>
            </Series>
            <ChartAreas>
                <asp:ChartArea>
                </asp:ChartArea>
            </ChartAreas>
        </asp:Chart>

        <asp:Chart runat="server">
        <Legends>
            <asp:Legend };
        string[] c = new string[] { "85","80", "50", "35" };
        for (int i = 0; i < 4; i++)
        {
            DataRow dr = dt.NewRow();
            dr["Country"] = n[i];
            dr["Score"] = c[i];
            dt.Rows.Add(dr);
        }
        return dt;
    }
}

asp.net微软图表控件使用示例代码分享

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表