Skip to main content
All docs
V24.2

Conditional Formatting

  • 4 minutes to read

Use conditional formatting to highlight points in a Scatter Chart dashboard item.

win-scatter-chart-cf

Supported Format Rules

You can use the following data in rule calculations:

The following table lists available format rules and corresponding data types:

Data Type

Supported Format Rules

numeric

Value

Top-Bottom

Average

Expression

Color Ranges

Gradient Ranges

string

Value with the condition type set to Equal To, Not Equal To or Text that Contains

Expression

date-time

Value

A Date Occurring for dimensions with a continuous date-time group interval

Expression

Color Ranges

Gradient Ranges

Refer to the following topic for more information about format condition types: Conditional Formatting Basics

Create and Edit a Format Rule

You can create and edit format rules in the following ways:

  • Click the Edit Rules button on the Home ribbon tab.

  • Click the measure/dimension menu button in the Data Item’s pane and select Add Format Rule/Edit Rules.

Refer to the following topic for information on how to create and edit format rules: Conditional Formatting in Windows Designer.

Format Condition Settings Specific to Scatter Charts

Specify appearance settings and set the condition’s value to create a format rule. Available settings depend on the selected format condition type.

The image below displays the Greater Than dialog (a Value format condition applied to a scatter chart). The condition colors bubbles if their values exceed 18.

win-scatter-chart-cf-appearance-settings-dialog

If you enable Display in Legend, the chart shows information about the applied rule. Set the Caption field to specify the legend’s text. The image below displays the Scatter Chart item with the applied Greater Than format rule. The Display in Legend option is activated and the rule’s caption is displayed in the legend:

win-scatter-chart-conditional-formatting

For Range format rules the legend display text is generated automatically and depends on the range intervals:

win-scatter-chart-with-range-rule

Coloring

A Scatter Chart item paints elements in pale gray if they do not meet the applied format condition. Note that this does not apply to elements that use the Hue color mode (the Dimension.ColoringMode property is set to Hue).

Select the Color by Hue option in a Data item’s pane to restore the color scheme.

win-scatter-chart-color-by-hue

Tip

Documentation: Scatter Chart - Coloring

Create a Format Rule in Code

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

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