Main Menu
Knowledge Base
Product Registration
Log an Incident
Request a Feature
Search Incidents/Bug Reports


Search KB

Please note: In an effort to better serve you, we are in the process of restructuring DevCenter. In the process, we have moved many items that you may be used to finding in DevCenter over to the Main Site. If you are having trouble locating something, please try looking at the following places:

Knowledge Base Article: KB09973

HOWTO:Drill down in WinChart [Part 3]


The information in this article applies to:
UltraWinChart (v6.1.20061)
  Article Created: 
6/22/2006

Last Updated:
6/23/2006

Article Type
How To
  
Page Options
Average Rating:
1 out of 10

Rate this page
Print this page
E-mail this page
Add to Favorites

Summary

..Continued..

Step-By-Step Example

Code: Chart Building Logic

VB.NET

    '///
    '/// This method accepts an argument, that depending on the
    '/// current drill level, represents one of several possible
    '/// entity fields (Customer ID, Order Number, etc...) and
    '/// then allows us to build a query to fetch data for one
    '/// of several drill levels
    '///

    '///
    Private Sub BuildChart(ByVal FieldValue As String)
        Dim theCommand As SqlCommand = New SqlCommand
        theCommand.Connection = Me.sqlConnection1
        theCommand.CommandType = CommandType.Text

        Dim s As String = String.Empty

        Select Case _currDrill

            Case 1 'FieldValue should be null at this level

                'Build the command
                s += " select TOP 10 a.customerID as 'Customer', count(b.OrderID) as 'Order Count' "
                s += " FROM "
                s += " Customers a, Orders b "
                s += " WHERE a.CustomerID = b.CustomerID "
                s += " GROUP BY a.CustomerID "
                s += " ORDER BY 2 DESC "

                theCommand.CommandText = s

                'Set Chart properties for this drill level:
                Me.ultraChart1.ChartType = ChartType.BarChart3D
                Me.ultraChart1.Legend.Visible = True

                'Set DataSource:
                Me.ultraChart1.Data.DataSource = Me.GetChartData(theCommand)

                'set link labels for this level:
                Me.lnk1.Text = "Root"

                Me.lnk1.Enabled = False
                Me.lnk1.Visible = True

                Me.lnk2.Enabled = False
                Me.lnk2.Visible = False

                Me.lnk3.Enabled = False
                Me.lnk3.Visible = False

                'set the ui labels for this level:
                Me.lbl1.Enabled = True
                Me.lbl2.Enabled = False
                Me.lbl3.Enabled = False

            Case 2 'Level 2: We can get the actual Orders PER customer

                'Build the command
                s += " select TOP 10 CONVERT(VARCHAR(10), a.OrderID) as 'Order ID', count(b.OrderID) as 'Line Items' "
                s += " FROM Orders a, [Order Details] b "
                s += " WHERE a.OrderID = b.OrderID AND "
                s += " a.CustomerID = @CustomerID "
                s += " group by a.OrderID order by 2 DESC "

                theCommand.CommandText = s

                theCommand.Parameters.Add("@CustomerID", FieldValue)

                'set Chart properties for this drill level:
                Me.ultraChart1.ChartType = ChartType.PieChart3D
                Me.ultraChart1.PieChart3D.Labels.FormatString = "<DATA_VALUE:0> Line Items"
                Me.ultraChart1.Legend.Visible = True

                'Set DataSource:
                Me.ultraChart1.Data.DataSource = Me.GetChartData(theCommand)

                'Set link labels for this level:
                Me.lnk1.Enabled = True
                Me.lnk1.Visible = True

                Me.lnk2.Text = FieldValue
                Me.lnk2.Enabled = False
                Me.lnk2.Visible = True

                Me.lnk3.Enabled = False
                Me.lnk3.Visible = False

                'set the ui labels for this level:
                Me.lbl1.Enabled = False
                Me.lbl2.Enabled = True
                Me.lbl3.Enabled = False

            Case 3

                'Build the command
                s += " select a.ProductName as 'Product', b.Quantity as 'Quantity' "
                s += " FROM Products a, [Order Details] b WHERE a.ProductID = b.ProductID "
                s += " AND b.OrderID = @OrderID ORDER BY b.Quantity ASC"

                theCommand.CommandText = s

                theCommand.Parameters.Add("@OrderID", FieldValue)

                'Set Chart properties for this drill level:
                Me.ultraChart1.ChartType = ChartType.CylinderColumnChart3D
                Me.ultraChart1.Legend.Visible = True

                'Set DataSource:
                Me.ultraChart1.Data.DataSource = Me.GetChartData(theCommand)

                'Set link labels for this level:
                Me.lnk1.Enabled = True
                Me.lnk1.Visible = True

                Me.lnk2.Enabled = True
                Me.lnk2.Visible = True

                Me.lnk3.Text = FieldValue
                Me.lnk3.Enabled = False
                Me.lnk3.Visible = True

                'set the ui labels for this level:
                Me.lbl1.Enabled = False
                Me.lbl2.Enabled = False
                Me.lbl3.Enabled = True

            Case Else
                Throw New ApplicationException("Unhandled Drill Level")

        End Select

    End Sub


..Continued..

Related Articles

HOWTO: Drill down in WinChart [Part 4] (KB09974)

HOWTO: Drill down in WinChart [Part 6] (KB09978)

HOWTO: Drill down in WinChart [Part 5] (KB09975)

HOWTO: Drill down in WinChart [Part 2] (KB09972)

HOWTO: Drill down in WinChart [Part 1] (KB09971)

Samples

winchart_drilldown.zip
 WinChart Drilldown Samples in C# and VB.NET



How would you rate the quality of this content?
Poor -----------------------------------------> Outstanding

Tell us why you rated the content this way. (optional)