How to: Color Dashboard Item Elements in the WinForms Viewer

  • 2 minutes to read

The following example demonstrates how to color dashboard item elements using the DashboardViewer.DashboardItemElementCustomColor event.

In this example, chart series points, whose values exceed specified thresholds, are colored in green. Chart series points, whose values fall below specified thresholds, are colored in red.

Pie segments, whose contributions in total fall below the specified threshold, are colored in orange.

View Example

Imports System.Drawing
Imports DevExpress.XtraEditors
Imports DevExpress.DashboardWin
Imports DevExpress.DashboardCommon
Imports DevExpress.DashboardCommon.ViewerData

Namespace Dashboard_ElementCustomColor
    Partial Public Class Form1
        Inherits XtraForm

        Public Sub New()
        End Sub

        Private Sub dashboardViewer1_DashboardItemElementCustomColor(ByVal sender As Object, _
                                     ByVal e As DashboardItemElementCustomColorEventArgs) _
                                 Handles dashboardViewer1.DashboardItemElementCustomColor

            Dim data As MultiDimensionalData = e.Data
            Dim currentElement As AxisPointTuple = e.TargetElement

            If e.DashboardItemName = "chartDashboardItem1" Then
                Dim country As String = _
                Dim value As Decimal = _
                If country = "UK" AndAlso value > 50000 OrElse country = "USA" AndAlso value > 100000 _
                    e.Color = Color.DarkGreen
                    e.Color = Color.DarkRed
                End If
            End If
            If e.DashboardItemName = "pieDashboardItem1" Then
                Dim value As Decimal = _
                If value < 100000 Then
                    e.Color = Color.Orange
                End If
            End If
        End Sub
    End Class
End Namespace
See Also