DashboardItemElementCustomColorEventArgs.Color Property
Gets or sets the color of the dashboard item element.
Namespace: DevExpress.DashboardWin
Assembly: DevExpress.Dashboard.v21.1.Win.dll
NuGet Package: DevExpress.Win.Dashboard
Declaration
Property Value
Type | Description |
---|---|
Color | A Color that is the ARGB color. |
Remarks
To specify the required dashboard item element, use the DashboardItemElementCustomColorEventArgs.TargetElement and DashboardItemElementCustomColorEventArgs.Measures properties.
Example
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.
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;
}
}
}
}
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Color 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.