濮阳杆衣贸易有限公司

主頁(yè) > 知識(shí)庫(kù) > asp.net微軟圖表控件使用示例代碼分享

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

熱門(mén)標(biāo)簽:電銷(xiāo)機(jī)器人 數(shù)據(jù) 廣州銷(xiāo)售外呼系統(tǒng)定制 ai電銷(xiāo)機(jī)器人對(duì)貸款有幫助嗎 宿遷智能外呼系統(tǒng)排名 地圖標(biāo)注多少錢(qián)一張 怎樣給陜西地圖標(biāo)注顏色 400電話辦理信任翰諾科技 云狐人工智能電話機(jī)器人 福州人工智能電銷(xiāo)機(jī)器人加盟

復(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è)置圖表類(lèi)型
        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)題的名稱(chēng)所在位置位遠(yuǎn)
        Chart1.ChartAreas["ChartArea1"].AxisY.Title = "金牌";//X軸標(biāo)題
        Chart1.ChartAreas["ChartArea1"].AxisY.TitleAlignment = StringAlignment.Far;//設(shè)置Y軸標(biāo)題的名稱(chēng)所在位置位遠(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è)置圖表類(lèi)型
        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)題的名稱(chēng)所在位置位遠(yuǎn)
        Chart2.ChartAreas["ChartArea1"].AxisY.Title = "金牌";//X軸標(biāo)題
        Chart2.ChartAreas["ChartArea1"].AxisY.TitleAlignment = StringAlignment.Far;//設(shè)置Y軸標(biāo)題的名稱(chēng)所在位置位遠(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è)置圖表類(lèi)型
        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)題的名稱(chēng)所在位置位遠(yuǎn)
        Chart3.ChartAreas["ChartArea1"].AxisY.Title = "金牌";//X軸標(biāo)題
        Chart3.ChartAreas["ChartArea1"].AxisY.TitleAlignment = StringAlignment.Far;//設(shè)置Y軸標(biāo)題的名稱(chēng)所在位置位遠(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è)置圖表類(lèi)型
        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類(lèi)型的數(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;
    }
}

您可能感興趣的文章:
  • .Net創(chuàng)建Excel文件(插入數(shù)據(jù)、修改格式、生成圖表)的方法
  • asp.net中一款極為簡(jiǎn)單實(shí)用的圖表插件(jquery)
  • ASP.NET 統(tǒng)計(jì)圖表控件小結(jié)
  • ASP.NET中實(shí)時(shí)圖表的實(shí)現(xiàn)方法分享
  • HighCharts圖表控件在ASP.NET WebForm中的使用總結(jié)(全)
  • ASP.NET MVC中圖表控件的使用方法
  • jquery jqPlot API 中文使用教程(非常強(qiáng)大的圖表工具)
  • javascript實(shí)現(xiàn)的柱狀統(tǒng)計(jì)圖表
  • JavaScript可視化圖表庫(kù)D3.js API中文參考
  • ASP.NET中制作各種3D圖表的方法

標(biāo)簽:大興安嶺 綿陽(yáng) 宜春 曲靖 焦作 延安 黃南 新疆

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《asp.net微軟圖表控件使用示例代碼分享》,本文關(guān)鍵詞  asp.net,微軟,圖表,控件,使用,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《asp.net微軟圖表控件使用示例代碼分享》相關(guān)的同類(lèi)信息!
  • 本頁(yè)收集關(guān)于asp.net微軟圖表控件使用示例代碼分享的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    建瓯市| 五大连池市| 怀化市| 贵港市| 德惠市| 全椒县| 宁化县| 淳安县| 虎林市| 滨海县| 宁海县| 库尔勒市| 临高县| 朝阳市| 天峻县| 章丘市| 左云县| 新宁县| 淳化县| 宝山区| 天峻县| 鄂托克前旗| 黄平县| 北京市| 万载县| 铜梁县| 长寿区| 石门县| 阳信县| 郑州市| 承德县| 布尔津县| 丁青县| 封丘县| 灵寿县| 百色市| 如东县| 岳池县| 同心县| 双峰县| 巴马|