欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

asp.net微軟圖表控件使用示例代碼分享

 更新時(shí)間:2013年12月20日 16:57:57   作者:  
這篇文章主要介紹了asp.net微軟圖表控件使用示例代碼,有需要的朋友可以參考一下

復(fù)制代碼 代碼如下:

<configuration>
  <system.webServer>
    <handlers>
      <remove name="ChartImageHandler" />
      <add name="ChartImageHandler" 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>

復(fù)制代碼 代碼如下:

<%@ 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 id="form1" runat="server">
    <div>
        <asp:Chart ID="Chart1" runat="server" Width="500px" BorderDashStyle="Solid" Palette="BrightPastel" imagetype="Png"  BackSecondaryColor="White" BackGradientStyle="TopBottom" BorderWidth="2" backcolor="#D3DFF0" BorderColor="26, 59, 105">
            <Titles>
                <asp:Title Font="微軟雅黑, 16pt" Name="Title1" Text="統(tǒng)計(jì)表">
                </asp:Title>
            </Titles>
            <borderskin skinstyle="Emboss"></borderskin>
            <Series>
                <asp:Series Name="Series1"  ChartType="Bubble" MarkerSize="8" MarkerStyle="Circle">
                </asp:Series>
            </Series>
            <ChartAreas>
                <asp:ChartArea Name="ChartArea1"  BorderColor="64, 64, 64, 64" BackSecondaryColor="Transparent" BackColor="64, 165, 191, 228" ShadowColor="Transparent" BackGradientStyle="TopBottom">
                </asp:ChartArea>
            </ChartAreas>
        </asp:Chart> 

        <asp:Chart ID="Chart2" runat="server">
            <Series>
                <asp:Series Name="Series1">
                </asp:Series>
            </Series>
            <ChartAreas>
                <asp:ChartArea Name="ChartArea1">
                </asp:ChartArea>
            </ChartAreas>
        </asp:Chart>
        <br/>

        <asp:Chart ID="Chart3" runat="server">
            <Series>
                <asp:Series Name="Series1">
                </asp:Series>
            </Series>
            <ChartAreas>
                <asp:ChartArea Name="ChartArea1">
                </asp:ChartArea>
            </ChartAreas>
        </asp:Chart>

        <asp:Chart ID="Chart4" runat="server">
        <Legends>
            <asp:Legend Title="金牌榜"></asp:Legend>
        </Legends>
            <Series>
                <asp:Series Name="Series1">
                </asp:Series>
            </Series>
            <ChartAreas>
                <asp:ChartArea Name="ChartArea1">
                </asp:ChartArea>
            </ChartAreas>
        </asp:Chart>
    </div>
    </form>
</body>
</html>

復(fù)制代碼 代碼如下:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;
//add
using System.Drawing;

public partial class chart : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        DataTable dt = CreatData();
        GetStyle1(dt);
        GetStyle2(dt);
        GetStyle3(dt);
        GetStyle4(dt);
    }


    protected void GetStyle1(DataTable dt)
    {
        #region 折線圖
        Chart1.DataSource = dt;//綁定數(shù)據(jù)
        Chart1.Series["Series1"].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Line;//設(shè)置圖表類型
        Chart1.Series[0].XValueMember = "Country";//X軸數(shù)據(jù)成員列
        Chart1.Series[0].YValueMembers = "Score";//Y軸數(shù)據(jù)成員列
        Chart1.ChartAreas["ChartArea1"].AxisX.Title = "國(guó)家";//X軸標(biāo)題
        Chart1.ChartAreas["ChartArea1"].AxisX.TitleAlignment = StringAlignment.Far;//設(shè)置Y軸標(biāo)題的名稱所在位置位遠(yuǎn)
        Chart1.ChartAreas["ChartArea1"].AxisY.Title = "金牌";//X軸標(biāo)題
        Chart1.ChartAreas["ChartArea1"].AxisY.TitleAlignment = StringAlignment.Far;//設(shè)置Y軸標(biāo)題的名稱所在位置位遠(yuǎn)
        Chart1.ChartAreas["ChartArea1"].AxisX.Interval = 1;//X軸數(shù)據(jù)的間距
        Chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不顯示豎著的分割線
        Chart1.Series[0].IsValueShownAsLabel = true;//顯示坐標(biāo)值
        #endregion
    }


    protected void GetStyle2(DataTable dt)
    {
        #region 樣條圖(平滑曲線)
        Chart2.DataSource = dt;//綁定數(shù)據(jù)
        Chart2.Series["Series1"].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Spline;//設(shè)置圖表類型
        Chart2.Series["Series1"].MarkerStyle = System.Web.UI.DataVisualization.Charting.MarkerStyle.Cross;//設(shè)置點(diǎn)的樣式,十字形
        Chart2.Series[0].XValueMember = "Country";//X軸數(shù)據(jù)成員列
        Chart2.Series[0].YValueMembers = "Score";//Y軸數(shù)據(jù)成員列
        Chart2.ChartAreas["ChartArea1"].AxisX.Title = "國(guó)家";//X軸標(biāo)題
        Chart2.ChartAreas["ChartArea1"].AxisX.TitleAlignment = StringAlignment.Far;//設(shè)置Y軸標(biāo)題的名稱所在位置位遠(yuǎn)
        Chart2.ChartAreas["ChartArea1"].AxisY.Title = "金牌";//X軸標(biāo)題
        Chart2.ChartAreas["ChartArea1"].AxisY.TitleAlignment = StringAlignment.Far;//設(shè)置Y軸標(biāo)題的名稱所在位置位遠(yuǎn)
        Chart2.ChartAreas["ChartArea1"].AxisX.Interval = 1;//X軸數(shù)據(jù)的間距
        Chart2.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不顯示豎著的分割線
        Chart2.Series[0].IsValueShownAsLabel = true;//顯示坐標(biāo)值
        #endregion
    }

    protected void GetStyle3(DataTable dt)
    {
        #region 條形圖
        Chart3.DataSource = dt;//綁定數(shù)據(jù)
        Chart3.Series["Series1"].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Bar;//設(shè)置圖表類型
        Chart3.Series[0].XValueMember = "Country";//X軸數(shù)據(jù)成員列
        Chart3.Series[0].YValueMembers = "Score";//Y軸數(shù)據(jù)成員列
        Chart3.ChartAreas["ChartArea1"].AxisX.Title = "國(guó)家";//X軸標(biāo)題
        Chart3.ChartAreas["ChartArea1"].AxisX.TitleAlignment = StringAlignment.Far;//設(shè)置Y軸標(biāo)題的名稱所在位置位遠(yuǎn)
        Chart3.ChartAreas["ChartArea1"].AxisY.Title = "金牌";//X軸標(biāo)題
        Chart3.ChartAreas["ChartArea1"].AxisY.TitleAlignment = StringAlignment.Far;//設(shè)置Y軸標(biāo)題的名稱所在位置位遠(yuǎn)
        Chart3.ChartAreas["ChartArea1"].AxisX.Interval = 1;//X軸數(shù)據(jù)的間距
        Chart3.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;//不顯示豎著的分割線
        Chart3.Series[0].IsValueShownAsLabel = true;//顯示坐標(biāo)值
        #endregion
    }


    protected void GetStyle4(DataTable dt)
    {
        #region 餅形圖
        Chart4.DataSource = dt;//綁定數(shù)據(jù)
        Chart4.Series["Series1"].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Pie;//設(shè)置圖表類型
        Chart4.Series[0].XValueMember = "Country";//X軸數(shù)據(jù)成員列
        Chart4.Series[0].YValueMembers = "Score";//Y軸數(shù)據(jù)成員列
        Chart4.Series[0].LegendMapAreaAttributes = "Country"; //顯示國(guó)家
        Chart4.Series[0].IsValueShownAsLabel = true;//顯示坐標(biāo)值
        #endregion

    }
    /// <summary>
    /// 創(chuàng)建一張二維數(shù)據(jù)表
    /// </summary>
    /// <returns>Datatable類型的數(shù)據(jù)表</returns>
    protected DataTable CreatData()
    {
        DataTable dt = new DataTable();
        dt.Columns.Add("Country", System.Type.GetType("System.String"));
        dt.Columns.Add("Score", System.Type.GetType("System.String"));
        string[] n = new string[] { "中國(guó)","美國(guó)", "俄羅斯", "英國(guó)" };
        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;
    }
}

相關(guān)文章

  • SQLServer 在Visual Studio的2種連接方法

    SQLServer 在Visual Studio的2種連接方法

    這篇文章介紹了SQLServer 在Visual Studio的2種連接方法,有需要的朋友可以參考一下
    2013-09-09
  • c# indexof 用法深入理解

    c# indexof 用法深入理解

    在開發(fā)過程中經(jīng)常會(huì)使用到c# indexof 查找字串中指定字符或字串首次出現(xiàn)的位置,返首索引值,本文將詳細(xì)介紹,需要的朋友可以參考下
    2012-11-11
  • asp.net core 系列之并發(fā)沖突的深入理解

    asp.net core 系列之并發(fā)沖突的深入理解

    這篇文章主要介紹了asp.net core 系列之并發(fā)沖突的深入理解,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-04-04
  • mvc上傳到美橙云虛擬機(jī)系列問題的解決方法

    mvc上傳到美橙云虛擬機(jī)系列問題的解決方法

    這篇文章主要為大家詳細(xì)介紹了mvc上傳到美橙云虛擬機(jī)系列問題的解決方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-10-10
  • ASP.net?core使用Autofac實(shí)現(xiàn)泛型依賴注入

    ASP.net?core使用Autofac實(shí)現(xiàn)泛型依賴注入

    這篇文章主要介紹了ASP.net?core使用Autofac實(shí)現(xiàn)泛型依賴注入的方式學(xué)習(xí),有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-04-04
  • 從客戶端檢測(cè)到有潛在危險(xiǎn)的Request.Form值的asp.net代碼

    從客戶端檢測(cè)到有潛在危險(xiǎn)的Request.Form值的asp.net代碼

    asp.net開發(fā)中,經(jīng)常遇到“從客戶端檢測(cè)到有潛在危險(xiǎn)的Request.Form 值”錯(cuò)誤提示,很多人給出的解決方案是
    2009-03-03
  • ASP.NET?Core管理應(yīng)用程序狀態(tài)

    ASP.NET?Core管理應(yīng)用程序狀態(tài)

    這篇文章介紹了ASP.NET?Core管理應(yīng)用程序狀態(tài)的方法,文中通過示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-04-04
  • ASP.NET MVC基礎(chǔ)

    ASP.NET MVC基礎(chǔ)

    這篇文章主要介紹了ASP.NET MVC基礎(chǔ)概念、MVC三大組件之間的相互關(guān)系、以及asp.net webform模型和ASP.NET MVC模型的關(guān)系等基礎(chǔ)知識(shí),是我們學(xué)習(xí)MVC必不可少的知識(shí)點(diǎn),希望對(duì)大家能有所幫助
    2014-10-10
  • FileUpload上傳圖片前實(shí)現(xiàn)圖片預(yù)覽功能(附演示動(dòng)畫)

    FileUpload上傳圖片前實(shí)現(xiàn)圖片預(yù)覽功能(附演示動(dòng)畫)

    FileUpload控件上傳圖片前實(shí)現(xiàn)預(yù)覽,很多網(wǎng)友都希望實(shí)現(xiàn)這樣的功能,本人總結(jié)了一下,感興趣的朋友可以參考一下,希望對(duì)您有幫助
    2013-01-01
  • log4net配置和使用方法分享

    log4net配置和使用方法分享

    這篇文章主要介紹了log4net配置和使用方法,大家參考使用吧
    2014-01-01

最新評(píng)論