ChartItemFormatRule Class
A format rule that is used to apply conditional formatting to the Chart dashboard item.
Namespace: DevExpress.DashboardCommon
Assembly: DevExpress.Dashboard.v24.1.Core.dll
NuGet Package: DevExpress.Dashboard.Core
Declaration
Remarks
Create a ChartItemFormatRule
object and specify its settings to add a format rule:
- Create a condition (a FormatConditionBase descendant), specify its settings, and assign it to the DashboardItemFormatRule.Condition property.
- Assign a data item (a measure/dimension) to the ChartItemFormatRuleBase.DataItem property. The data item’s value is used to calculate the condition.
- Use the ChartItemFormatRule.ApplyToSeries property to specify the series to which a format rule is applied.
- Assign a FormatRuleChartElement value to the ChartItemFormatRule.ApplyToChartElement property. This property specifies the chart element to be highlighted.
- Add the format rule to the ChartDashboardItem.FormatRules collection.
Set ChartItemFormatRuleBase.ShowInLegend property to true to display a rule in a chart’s legend. Use the ChartItemFormatRuleBase.DisplayName property to specify the rule’s caption that is displayed in a legend.
The following code snippet shows how to apply the Gradient Range and Value rules to the Chart Dashboard item:
public Form1() {
InitializeComponent();
ChartDashboardItem chart1 = (ChartDashboardItem)dashboardDesigner1.Dashboard.Items["chartDashboardItem1"];
ChartDashboardItem chart2 = (ChartDashboardItem)dashboardDesigner1.Dashboard.Items["chartDashboardItem2"];
AddFormatRulesToBarSeries(chart1);
AddFormatRulesToLineSeries(chart2);
}
public void AddFormatRulesToBarSeries(ChartDashboardItem chart) {
SimpleSeries series = chart.Panes[0].Series[0] as SimpleSeries;
ChartItemFormatRule gradientRule = new ChartItemFormatRule(series.Value, series);
FormatConditionRangeGradient condition = new FormatConditionRangeGradient(FormatConditionRangeGradientPredefinedType.RedBlue);
gradientRule.Condition = condition;
gradientRule.ShowInLegend = false;
chart.FormatRules.Add(gradientRule);
}
public void AddFormatRulesToLineSeries(ChartDashboardItem chart) {
SimpleSeries series = chart.Panes[0].Series[0] as SimpleSeries;
ChartItemFormatRule valueRule1 = new ChartItemFormatRule(series.Value, series);
FormatConditionValue valueCondition1 = new FormatConditionValue(DashboardFormatCondition.Greater, 3000);
valueCondition1.StyleSettings = new ColorStyleSettings(Color.Green);
valueRule1.Condition = valueCondition1;
valueRule1.ShowInLegend = true;
valueRule1.Description = "UnitPrice greater than $3K";
chart.FormatRules.Add(valueRule1);
}
Inheritance
Object
DashboardItemFormatRule
ChartItemFormatRuleBase
ChartItemFormatRule
See Also