Back to Devexpress

DashboardItemControlEventArgs.ChartContext Property

dashboard-devexpress-dot-dashboardwin-dot-dashboarditemcontroleventargs-bec5fd25.md

latest7.1 KB
Original Source

DashboardItemControlEventArgs.ChartContext Property

Gets the chart context.

Namespace : DevExpress.DashboardWin

Assembly : DevExpress.Dashboard.v25.2.Win.dll

NuGet Package : DevExpress.Win.Dashboard

Declaration

csharp
public ChartContext ChartContext { get; }
vb
Public ReadOnly Property ChartContext As ChartContext

Property Value

TypeDescription
ChartContext

A context used to provide a connection between data item containers from the Values section and underlying control’s series.

|

Remarks

A chart context provides the connection between dashboard data item containers from the Values section and the underlying control’s series. The GetControlSeries method returns a data item container that corresponds to the specified control’s series. The GetDashboardItemColumn method, in turn, gets a collection of the control’s series that corresponds to the specified data item containers from the Values section.

The following code shows how to change the standard line to a line consisting of a repeating pattern of dash-dot. The Chart contains two panes with Total Sum and Quantity data items. The series contains two values. The DashboardDesigner.DashboardItemControlUpdated event is used to update the Chart’s appearance.

csharp
using DevExpress.DashboardCommon;
using DevExpress.DashboardWin;
using DevExpress.XtraCharts;

// ...

private void DashboardDesigner1_DashboardItemControlUpdated(object sender, DashboardItemControlEventArgs e) {
    if(e.ChartControl != null) {
        DashboardDesigner designer = (DashboardDesigner)sender;
        var chartDashboardItem = designer.Dashboard.Items[e.DashboardItemName] as ChartDashboardItem;

        foreach(var pane in chartDashboardItem.Panes) {
            if(pane.Series.Count > 0) {
                foreach(var dashSeries in pane.Series) {
                    if(dashSeries != null) {
                        var controlSeries = e.ChartContext.GetChartSeries(dashSeries);
                        if(controlSeries != null) {
                            foreach(var ser in controlSeries) {
                                LineSeriesView view = ser.View as LineSeriesView;
                                if(view != null) {
                                    view.LineStyle.DashStyle = DashStyle.DashDot;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
vb
Imports DevExpress.DashboardCommon
Imports DevExpress.DashboardWin
Imports DevExpress.XtraCharts

' ...

Private Sub DashboardDesigner1_DashboardItemControlUpdated(ByVal sender As Object, ByVal e As DashboardItemControlEventArgs)

Private Sub DashboardDesigner1_DashboardItemControlUpdated(ByVal sender As Object, ByVal e As DashboardItemControlEventArgs)
    If e.ChartControl IsNot Nothing Then
        Dim designer As DashboardDesigner = CType(sender, DashboardDesigner)
        Dim chartDashboardItem = TryCast(designer.Dashboard.Items(e.DashboardItemName), ChartDashboardItem)

        For Each pane In chartDashboardItem.Panes
            If pane.Series.Count > 0 Then
                For Each dashSeries In pane.Series
                    If dashSeries IsNot Nothing Then
                        Dim controlSeries = e.ChartContext.GetChartSeries(dashSeries)
                        If controlSeries IsNot Nothing Then
                            For Each ser In controlSeries
                                Dim view As LineSeriesView = TryCast(ser.View, LineSeriesView)
                                If view IsNot Nothing Then
                                    view.LineStyle.DashStyle = DashStyle.DashDot
                                End If
                            Next ser
                        End If
                    End If
                Next dashSeries
            End If
        Next pane
    End If
End Sub

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the ChartContext 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.

winforms-dashboard-custom-properties/CS/WinForms-Dashboard-Custom-Properties/Modules/ConstantLineUserValueModule.cs#L81

csharp
if(e.ChartControl != null && designer.Dashboard.Items[e.DashboardItemName] is ChartDashboardItem chartDashboardItem)
        UpdateChart(chartDashboardItem, e.ChartContext);
}

winforms-dashboard-custom-properties/VB/WinForms-Dashboard-Custom-Properties/Modules/ConstantLineUserValueModule.vb#L86

vb
If e.ChartControl IsNot Nothing AndAlso tempVar Then
    UpdateChart(chartDashboardItem, e.ChartContext)
End If

See Also

DashboardItemControlEventArgs Class

DashboardItemControlEventArgs Members

DevExpress.DashboardWin Namespace