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: KB09978

HOWTO:Drill down in WinChart [Part 6]


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: Drilling Back through the UI

VB.NET

    '///
    '/// This takes us to the ROOT level again
    '///

    '///
    '///
    Private Sub lnk1_Click(ByVal sender As Object, _
        ByVal e As System.EventArgs) Handles lnk1.Click
        _currDrill = MIN_DRILL 'set drill level to the beginning
        Me.BuildChart(Nothing) 'build the chart just like we do in the form load
    End Sub

    '///
    '/// Takes us to level 2
    '///

    '///
    '///
    Private Sub lnk2_Click(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles lnk2.Click
        _currDrill = 2
        Me.BuildChart(Me.lnk2.Text)
    End Sub

    '///
    '/// This will never be called since 3 is the last level, but this
    '/// shows the pattern to use if you had more levels of drilling
    '///

    '///
    '///
    Private Sub lnk3_Click(ByVal sender As Object, _
        ByVal e As System.EventArgs) Handles lnk3.Click
        _currDrill = 3     'Force the level to 3
        Me.BuildChart(Me.lnk3.Text)     'build the chart
    End Sub

C#

        ///
        /// This takes us to the ROOT level again
        ///

        ///
        ///
        private void lnk1_LinkClicked(object sender,
            System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            _currDrill = MIN_DRILL; //set drill level to the beginning
            this.BuildChart(null); //build the chart just like we do in the form load
        }

        ///
        /// Takes us to level 2
        ///

        ///
        ///
        private void lnk2_LinkClicked(object sender,
            System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            _currDrill = 2;
            this.BuildChart( this.lnk2.Text );
        }

        ///
        /// This will never be called since 3 is the last level, but this
        /// shows the pattern to use
        ///

        ///
        ///
        private void lnk3_LinkClicked(object sender,
            System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            _currDrill = 3;                            //Force the level to 3
            this.BuildChart( this.lnk3.Text );    //build the chart
        }

The end user will be able to drill back to any level simply by clicking on any of the visible Link Labels. Since when we drilled down into the chart, we populated the Link Label Text property with the value that was used to perform the query, drilling back to any previous level will not be a problem because we have the same information to requery the database. The Logic in the Link Label Click event is simple; we set the current drill level to a value that represents the Link we clicked (each link label represents a known drill level) and then we build the chart, passing in the value of the link label’s text property so that the Chart is built using the same information that was used to get to that level previously.

Improvements for scalability

Aside from the obvious changes that can be made to this sample regarding the separation of logic from the UI, Business Logic and Data Access, another improvement could be implemented so that rather than using the Text property of each Link Label, we could create a collection of custom objects that store the value(s) that were used to reach each particular drill level. Whenever we enter each drill level by clicking on a Link Label, we can query the objects at that index (+1 since it is a 0 based index) and then retrieve the data again.

Review:

Now that we have seen how simple it is to achieve Chart Drilldown, implementing your own should be a rewarding experience. Please feel free to download the included sample which includes versions in VB.NET and C#. You will need to point to an instance of SQL Server that contains the Northwind database. The connection string is currently configured to point to your local pc.

[End of article]

Related Articles

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

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

HOWTO: Drill down in WinChart [Part 3] (KB09973)

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)