Skip to main content

DrillDownStateChangedEventArgs.States Property

Returns the array of states that specify filtering parameters applied on each detail level.

Namespace: DevExpress.XtraCharts

Assembly: DevExpress.XtraCharts.v23.2.dll

NuGet Package: DevExpress.Charts

Declaration

public DrillDownItem[] States { get; }

Property Value

Type Description
DrillDownItem[]

States that specify filtering parameters applied on each detail level.

Remarks

The following example demonstrates how to use the property to change several diagram settings taking into account the current drill down state.

Example

chartControl.DrillDownStateChanged += this.OnChartControlDrillDownStateChanged;
chartControl.DrillDownStateChanging += this.OnChartControlDrillDownStateChanging;

private void OnChartControlDrillDownStateChanging(object sender, DrillDownStateChangingEventArgs e) {
    if (e.States.Length != 0) {
        object categoryValue = null;
        if (e.States.Last().Parameters.TryGetValue("Category", out categoryValue)) {
            int seriesIndex = chartControl.Series.IndexOf(chartControl.Series[(string)categoryValue]);
            int colorIndex = seriesIndex % chartControl.PaletteRepository[chartControl.PaletteName].Count + 1;
            chartControl.PaletteBaseColorNumber = colorIndex;
        }
        if (chartControl.Diagram is XYDiagram diagram) {
            diagram.AxisX.Label.Font = new Font("Tahoma", 8.25f, FontStyle.Regular);
        }
    } else {
        chartControl.PaletteBaseColorNumber = 0;
        if (chartControl.Diagram is XYDiagram diagram) {
            diagram.AxisX.Label.Font = new Font("Tahoma", 8.25f, FontStyle.Underline);
        }
    }
}
private void OnChartControlDrillDownStateChanged(object sender, DrillDownStateChangedEventArgs e) {
    if (!(chartControl.Diagram is XYDiagram diagram)) return;
    if (e.States.Length == 0) {
        diagram.Rotated = true;
        return;
    }
    diagram.Rotated = IsDrillToSeriesFromHome(e.States);
}
private bool IsDrillToSeriesFromHome(DrillDownItem[] drillDownItems) {
    if (drillDownItems.Length != 1) return false;
    IReadOnlyDictionary<string, object> drillDownParams = drillDownItems[0].Parameters;
    if (drillDownParams.Count != 1) return false;
    return drillDownParams.ContainsKey("Category");
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the States property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also