Skip to main content
A newer version of this page is available. .
All docs
V20.2

ScatterChartItemFormatRule Class

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

Namespace: DevExpress.DashboardCommon

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

NuGet Packages: DevExpress.Dashboard.Core, DevExpress.WindowsDesktop.Dashboard.Core

Declaration

public class ScatterChartItemFormatRule :
    ChartItemFormatRuleBase

Remarks

To add a format rule, create a ScatterChartItemFormatRule object and specify its settings:

Set the ChartItemFormatRuleBase.ShowInLegend property to true to display a rule in a scatter chart’s legend. Use the ChartItemFormatRuleBase.DisplayName property to specify the rule’s caption that is displayed in a legend.

Example 1: Create a Value Format Rule

The following code snippet applies the Value format rule to the Scatter Chart dashboard item. The rule applies green to elements whose ExtendedPrice value exceeds 200,000.

public Form1() {
    InitializeComponent();
    ScatterChartDashboardItem scatterChart1 = (ScatterChartDashboardItem)dashboardDesigner1.Dashboard.Items["scatterChartDashboardItem1"];
    AddFormatRulesToScatterChart(scatterChart1);
}
public void AddFormatRulesToScatterChart(ScatterChartDashboardItem scatterChart) {
    ScatterChartItemFormatRule valueRule1 = new ScatterChartItemFormatRule();
    valueRule1.DataItem = scatterChart.AxisYMeasure;
    FormatConditionValue valueCondition1 = new FormatConditionValue(DashboardFormatCondition.Greater, 200000);
    valueCondition1.StyleSettings = new ColorStyleSettings(Color.Green);
    valueRule1.Condition = valueCondition1;
    valueRule1.ShowInLegend = true;
    valueRule1.DisplayName = "ExtendedPrice is greater than $200K";
    scatterChart.FormatRules.Add(valueRule1);
}

Example 2: Create an Expression Format Rule

View Example: How to Highlight Data in a Scatter Chart Dashboard Item

The following code snippet applies the Expression format rule to the Scatter Chart dashboard item. The rule colors elements if their corresponding X axis value exceeds 18 and Y axis value exceeds 7,000.

public Form1() {
    InitializeComponent();
    ScatterChartDashboardItem scatterChart1 = (ScatterChartDashboardItem)dashboardDesigner1.Dashboard.Items["scatterChartDashboardItem1"];
    AddFormatRulesToScatterChart(scatterChart1);
}
public void AddFormatRulesToScatterChart(ScatterChartDashboardItem scatterChart) {
    double unitCountThreshold = 7000;
    double discountThreshold = 18;
    ScatterChartItemFormatRule expressionRule1 = new ScatterChartItemFormatRule();
    expressionRule1.DataItem = scatterChart.AxisYMeasure;
    FormatConditionExpression formatCondition = new FormatConditionExpression();
    formatCondition.Expression = $"{scatterChart.AxisYMeasure.UniqueId} > {unitCountThreshold} && {scatterChart.AxisXMeasure.UniqueId} > {discountThreshold}";
    formatCondition.StyleSettings = new ColorStyleSettings(ColorTranslator.FromHtml("#14abb7"));
    expressionRule1.Condition = formatCondition;
    expressionRule1.ShowInLegend = true;
    expressionRule1.DisplayName = "Discount amount from the quantity of products sold";
    scatterChart.FormatRules.Add(expressionRule1);
}

Inheritance

See Also