Skip to main content

How to: Implement the Drill-Down Functionality in Sunburst

  • 2 minutes to read

Drill-Down allows users to change the detail level of data displayed in a sunburst. This example shows how to create a drill-down sunburst.

Drill Down Sunburst Animation

  1. Subscribe the Sunburst control’s MouseUp event.

  2. In the event hander, replace the existing adapter data source with data associated with the selected sunburst item’s Tag property to drill through the item. Tag stores user data objects that the Sunburst control uses to create the item and its child items.

  3. You can use a stack to save the adapter data source’s states to implement the ‘Drill up’ action.

void sunburstControl1_MouseUp(object sender, MouseEventArgs e) {
    SunburstHitInfo shi = sunburstControl1.CalcHitInfo(e.Location);
    if(shi.InSunburstItem) {
        TypeInfo drillDownDataSource = (TypeInfo)shi.SunburstItem.Tag;
        if(DataAdapter.DataSource != drillDownDataSource) {
            dataStack.Push(new DataSourceInfo(DataAdapter.DataSource, sunburstControl1.CenterLabel.TextPattern));
            DataAdapter.DataSource = drillDownDataSource;
            sunburstControl1.CenterLabel.TextPattern += "." + drillDownDataSource.NamespaceString;
        }
    }
    else if(shi.InCenterLabel && dataStack.Count > 0) {
        DataSourceInfo sourceInfo = dataStack.Pop();
        DataAdapter.DataSource = sourceInfo.Source;
        sunburstControl1.CenterLabel.TextPattern = sourceInfo.Label;
    }
}

The following table lists the API members the code above uses:

Member Description
SunburstHitInfo Contains information about the Sunburst element that is under the test point.
SunburstHitInfo.InSunburstItem Returns the value that specifies whether the cursor is over a sunburst item.
SunburstHierarchicalDataAdapter.DataSource Gets or sets the object that is the data adapter’s data source.
SunburstItem.Tag Gets or sets the object that contains data related to a sunburst item.