⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 drilldownnodategrouping.aspx

📁 掌握学习.net开发的非常好的资料
💻 ASPX
字号:
<%@ Page Debug="true" Trace="false" Language="VB" Description="dotnetCHARTING Component" %>
<%@ Register TagPrefix="dotnet"  Namespace="dotnetCHARTING" Assembly="dotnetCHARTING"%>
<%@ Import Namespace="System.Drawing" %>


<script runat="server">
Sub Page_Load(sender As [Object], e As EventArgs)
   
   Chart.Type = ChartType.Combo 'Horizontal;
   Chart.Debug = True
   Chart.TempDirectory = "temp"
   Chart.DefaultSeries.DefaultElement.ToolTip = "Population: %yvalue"
   
   Dim connection As String = "Provider=Microsoft.Jet.OLEDB.4.0;data source=" + Server.MapPath("../../database/chartsample.mdb")
   Dim sql As String = ""
   
   ' This sample will demonstrate how a custom drill down chart can be created.
   ' The database is not provided. The structure of this database would be something like this:
   ' COUNTRIES Table:
   ' CountryID	Country		Population
   ' STATES Table:
   ' StateID		State		Population	CountryID
   ' CITIES Table
   ' CityID		City		Population	StateID
   ' First we show all the countries in the database. When a country is clicked we show the states within
   ' the country. When a state is clicked we show the cities within it.
   ' Instantiate a data engine object and set the connection string.
   Dim de As New DataEngine()
   de.ConnectionString = connection
   
   ' Instantiate a series collection for later use.
   Dim sc As New SeriesCollection()
   
   ' Test the querystring to see what level in the drill down we are at.
   ' Level 1 = Country
   ' Level 2 = State
   ' Level 3 = City
   If Request.QueryString("ddLevel") Is Nothing Or Request.QueryString("ddLevel") = "" Then
   		Chart.Title="Countries Population"
      ' If the query string is empty this is the first level.
      ' We are on the first level (country)
      de.SqlStatement = "SELECT Country, CountryID, Population FROM Countries"
      
      ' We specify the element fields where the database data will be stored.
      de.DataFields = "xAxis=Country,yAxis=Population,Url=CountryID"
      
      sc = de.GetSeries()
      ' We now have the data for countries. We will want to itterate through the elements
      ' URL values and modify them for the next drill down level.
      Dim s As Series
      For Each s In  sc
         Dim el As Element
         For Each el In  s.Elements
            el.URL = "?id=" + el.URL + "&ddLevel=2"
         Next el
      Next s
   Else
      If Request.QueryString("ddLevel") = "2" Then
      	  Chart.Title="State/Province Population"
         ' We are on the second level (state)
         ' We make the sql query using the passed id.
         de.SqlStatement = "SELECT State, StateID, Population FROM States WHERE CountryID = " + Request.QueryString("id")
         
         ' We specify the element fields where the database data will be stored.
         de.DataFields = "xAxis=State,yAxis=Population,Url=StateID"
         
         sc = de.GetSeries()
         ' We now have the data for states. We will iterate through the elements
         ' URL values and modify them for the next drill down level.
         Dim s As Series
         For Each s In  sc
            Dim el As Element
            For Each el In  s.Elements
               el.URL = "?id=" + el.URL + "&ddLevel=3"
            Next el
         Next s
      Else
         If Request.QueryString("ddLevel") = "3" Then
         	Chart.Title="Cities Population"
            ' We are on the third level (city)
            ' We make the sql query using the passed id.
            de.SqlStatement = "SELECT City, CityID, Population FROM Cities WHERE StateID = " + Request.QueryString("id")
            
            ' We specify the element fields where the database data will be stored.
            de.DataFields = "xAxis=City,yAxis=Population"
            
            ' Since this is the last level we don抰 have to process the urls
            sc = de.GetSeries()
         End If
      End If
   End If
   ErrorMessage.Text = de.ErrorMessage
   
   
   
   
   ' Add the data.
   Chart.SeriesCollection.Add(sc)
End Sub 'Page_Load 

</script>
<HTML><HEAD><TITLE>DrillDown Without Date Grouping</TITLE></HEAD>
<BODY>
<DIV align=center>
 <dotnet:Chart id="Chart"  runat="server"/>
 <Asp:Label id="ErrorMessage"  runat="server"/>

</DIV>
</BODY>
</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -