Skip to main content

ColorScaleFormatCondition Class

Represents a color scale format condition.

Namespace: DevExpress.Xpf.PivotGrid

Assembly: DevExpress.Xpf.PivotGrid.v24.2.dll

NuGet Package: DevExpress.Wpf.PivotGrid

Declaration

public class ColorScaleFormatCondition :
    IndicatorFormatConditionBase

Remarks

A ColorScaleFormatCondition object allows you to display data distribution and variation using a gradation of two or three colors. The shade of the color represents higher, middle (three-color scale only) or lower values. For example, in a red, yellow and green three-color scale, you can specify that higher value cells have a more green color, middle value cells have a yellow color and lower value cells have a more red color.

Conditional Formatting - ColorScale

The ColorScaleFormatCondition class is inherited from the FormatConditionBase base class and represents a color scale format condition. To apply conditional formatting, create a new ColorScaleFormatCondition instance, specify its parameters and add it to the PivotGridControl.FormatConditions collection.

By default, the minimum and maximum values in a data cells are calculated automatically. To manually specify the values to regard as the minimum and maximum, use the IndicatorFormatConditionBase.MinValue and IndicatorFormatConditionBase.MaxValue properties.

For each color scale condition, you can select one of the predefined formats or apply a custom color scale format.

The following code sample shows how to apply the ColorScale format condition with the predefined format.

using DevExpress.Xpf.PivotGrid;

public MainWindow()
{
    // ...

    // Creates a new ColorScaleFormatCondition instance.
    ColorScaleFormatCondition formatRuleColorScale = new ColorScaleFormatCondition();

    // Configures the ColorScale format condition.
    formatRuleColorScale.ApplyToSpecificLevel = true;
    formatRuleColorScale.ColumnName = "fieldQuarter";
    formatRuleColorScale.RowName = "fieldSalesPerson";
    formatRuleColorScale.MeasureName = "fieldExtendedPrice";
    formatRuleColorScale.PredefinedFormatName = "RedYellowGreenColorScale";

    // Adds this instance to the FormatConditionCollection.
    pivotGridControl1.AddFormatCondition(formatRuleColorScale);
}
See Also