The following example demonstrates how to color dashboard item elements using the ASPxClientDashboard.ItemElementCustomColor 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.
var argumentAxis = DashboardDataAxisNames.ChartArgumentAxis,
seriesAxis = DashboardDataAxisNames.ChartSeriesAxis;
function setColors(args) {
var chartClientData = webViewer.GetItemData("chartDashboardItem1"),
pieClientData = webViewer.GetItemData("pieDashboardItem1");
var currentElement = args.GetTargetElement();
if (args.ItemName == "chartDashboardItem1") {
var country = currentElement.GetAxisPoint(DashboardDataAxisNames.ChartSeriesAxis).GetValue();
var value = chartClientData.GetSlice(currentElement.GetAxisPoint(argumentAxis)).
GetSlice(currentElement.GetAxisPoint(seriesAxis)).
GetMeasureValue(chartClientData.GetMeasures()[0].Id).GetValue();
if (country == "UK" && value > 50000 || country == "USA" && value > 100000)
args.SetColor("#33CC66");
else
args.SetColor("#CC6633");
}
if (args.ItemName == "pieDashboardItem1") {
var value = pieClientData.GetSlice(currentElement.GetAxisPoint(argumentAxis)).
GetMeasureValue(pieClientData.GetMeasures()[0].Id).GetValue();
if (value < 100000)
args.SetColor("#FFCC66");
}
};
var argumentAxis = DashboardDataAxisNames.ChartArgumentAxis,
seriesAxis = DashboardDataAxisNames.ChartSeriesAxis;
function setColors(args) {
var chartClientData = webViewer.GetItemData("chartDashboardItem1"),
pieClientData = webViewer.GetItemData("pieDashboardItem1");
var currentElement = args.GetTargetElement();
if (args.ItemName == "chartDashboardItem1") {
var country = currentElement.GetAxisPoint(DashboardDataAxisNames.ChartSeriesAxis).GetValue();
var value = chartClientData.GetSlice(currentElement.GetAxisPoint(argumentAxis)).
GetSlice(currentElement.GetAxisPoint(seriesAxis)).
GetMeasureValue(chartClientData.GetMeasures()[0].Id).GetValue();
if (country == "UK" && value > 50000 || country == "USA" && value > 100000)
args.SetColor("#33CC66");
else
args.SetColor("#CC6633");
}
if (args.ItemName == "pieDashboardItem1") {
var value = pieClientData.GetSlice(currentElement.GetAxisPoint(argumentAxis)).
GetMeasureValue(pieClientData.GetMeasures()[0].Id).GetValue();
if (value < 100000)
args.SetColor("#FFCC66");
}
};