dashboard-devexpress-dot-dashboardwin-dot-dashboarditemelementcustomcoloreventargs-700b9d22.md
Gets or sets the color of the dashboard item element.
Namespace : DevExpress.DashboardWin
Assembly : DevExpress.Dashboard.v25.2.Win.dll
NuGet Package : DevExpress.Win.Dashboard
public Color Color { get; set; }
Public Property Color As Color
| Type | Description |
|---|---|
| Color |
A Color that is the ARGB color.
|
To specify the required dashboard item element, use the DashboardItemElementCustomColorEventArgs.TargetElement and DashboardItemElementCustomColorEventArgs.Measures properties.
The following code snippets show 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.
using System.Drawing;
using DevExpress.XtraEditors;
using DevExpress.DashboardWin;
using DevExpress.DashboardCommon;
using DevExpress.DashboardCommon.ViewerData;
namespace Dashboard_ElementCustomColor {
public partial class Form1 : XtraForm {
public Form1() {
InitializeComponent();
dashboardViewer1.LoadDashboard(@"..\..\Data\Dashboard.xml");
}
private void dashboardViewer1_DashboardItemElementCustomColor(object sender,
DashboardItemElementCustomColorEventArgs e) {
MultiDimensionalData data = e.Data;
AxisPointTuple currentElement = e.TargetElement;
if (e.DashboardItemName == "chartDashboardItem1") {
string country =
currentElement.GetAxisPoint(DashboardDataAxisNames.ChartSeriesAxis).Value.ToString();
decimal value = (decimal)(data.GetSlice(currentElement)).GetValue(e.Measures[0]).Value;
if (country == "UK" && value > 50000 || country == "USA" && value > 100000)
e.Color = Color.DarkGreen;
else
e.Color = Color.DarkRed;
}
if (e.DashboardItemName == "pieDashboardItem1") {
decimal value =
(decimal)(data.GetSlice(currentElement)).GetValue(data.GetMeasures()[0]).Value;
if (value < 100000)
e.Color = Color.Orange;
}
}
}
}
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()
InitializeComponent()
dashboardViewer1.LoadDashboard("..\..\Data\Dashboard.xml")
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 = _
currentElement.GetAxisPoint(DashboardDataAxisNames.ChartSeriesAxis).Value.ToString()
Dim value As Decimal = _
CDec((data.GetSlice(currentElement)).GetValue(e.Measures(0)).Value)
If country = "UK" AndAlso value > 50000 OrElse country = "USA" AndAlso value > 100000 _
Then
e.Color = Color.DarkGreen
Else
e.Color = Color.DarkRed
End If
End If
If e.DashboardItemName = "pieDashboardItem1" Then
Dim value As Decimal = _
CDec((data.GetSlice(currentElement)).GetValue(data.GetMeasures()(0)).Value)
If value < 100000 Then
e.Color = Color.Orange
End If
End If
End Sub
End Class
End Namespace
See Also
DashboardItemElementCustomColorEventArgs Class