Back to Devexpress

ColorScaleFormatCondition Class

wpf-devexpress-dot-xpf-dot-pivotgrid-b3a3c38b.md

latest5.1 KB
Original Source

ColorScaleFormatCondition Class

Represents a color scale format condition.

Namespace : DevExpress.Xpf.PivotGrid

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

NuGet Package : DevExpress.Wpf.PivotGrid

Declaration

csharp
public class ColorScaleFormatCondition :
    IndicatorFormatConditionBase
vb
Public Class ColorScaleFormatCondition
    Inherits 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.

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.

csharp
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);
}
vb
Imports DevExpress.Xpf.PivotGrid

Public Sub New()
    ' ...

    ' Creates a new ColorScaleFormatCondition instance.
    Dim formatRuleColorScale As 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)
End Sub

Inheritance

Object DispatcherObject DependencyObject FormatConditionBase IndicatorFormatConditionBase ColorScaleFormatCondition

See Also

ColorScaleFormatCondition Members

DevExpress.Xpf.PivotGrid Namespace