Skip to main content
All docs
V24.2

ChartItemFormatRule Class

A format rule that is used to apply conditional formatting to the Chart dashboard item.

Namespace: DevExpress.DashboardCommon

Assembly: DevExpress.Dashboard.v24.2.Core.dll

Declaration

public class ChartItemFormatRule :
    ChartItemFormatRuleBase

Remarks

Create a ChartItemFormatRule object and specify its settings to add a format rule:

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);
}
See Also