FormatConditionGradientRangeBar Class

A format condition used to visualize numeric values using bars whose colors are contained in the specified color gradient.

Namespace: DevExpress.DashboardCommon
Assembly: DevExpress.Dashboard.v18.1.Core.dll
Syntax
public class FormatConditionGradientRangeBar : FormatConditionRangeGradient, IAggregationInfo, IFormatCondition, IXmlSerializableElement, IFormatStyleSettingsOwner, IMinMaxInfo

Range gradient conditions allow you to apply formatting using value ranges and a specified color gradient. You can specify whether an absolute or percent scale is used to define range boundaries using the FormatConditionRangeBase.ValueType property.

To create a format condition to display bars of different colors (from the specified color gradient) with lengths proportional to corresponding values, use the following approaches.

  1. To use a predefined set of start/end colors to create a color gradient, pass the required FormatConditionRangeGradientPredefinedType enumeration value to the FormatConditionRangeGradient constructor or to the corresponding FormatConditionGradientRangeBar.Generate method overload.
  2. To use custom colors and a specified number of ranges to create color gradient, pass the required start/end colors (by initializing the BarStyleSettings object) and number of ranges to the FormatConditionRangeGradient constructor or to the corresponding FormatConditionGradientRangeBar.Generate method overload.
  3. To use custom colors and specified range boundaries to create a color gradient, pass the required start/end colors (by initializing the BarStyleSettings object) and an array of boundary values to the FormatConditionRangeGradient constructor or to the corresponding FormatConditionGradientRangeBar.Generate method overload. You can also specify boundary values by calling the FormatConditionRangeBase.SetValues method.
  4. To use custom range boundaries and the required style specified for each range, do the following.

Assign the resulting FormatConditionGradientRangeBar object to the DashboardItemFormatRule.Condition property.

Examples

The Bar Gradient Ranges condition (FormatConditionGradientRangeBar) allows you to visualize numeric values using bars whose colors are contained in the specified color gradient.

This example shows how to apply conditional formatting to Grid cells using the predefined Red-Blue color gradient. Use the Update Formatting button to change start/end colors and the number of ranges in the color gradient. The third color in the middle of the color scale is also specified to generate a 3-color gradient.

´╗┐Imports DevExpress.DashboardCommon
Imports System.Drawing

Namespace Grid_IconRangeCondition
    Partial Public Class Form1
        Inherits DevExpress.XtraEditors.XtraForm

        Public Sub New()
            InitializeComponent()
            Dim dashboard As New Dashboard()
            dashboard.LoadFromXml("..\..\Data\Dashboard.xml")
            dashboardViewer1.Dashboard = dashboard
            Dim grid As GridDashboardItem = CType(dashboard.Items("gridDashboardItem1"), GridDashboardItem)
            Dim extendedPrice As GridMeasureColumn = CType(grid.Columns(1), GridMeasureColumn)

            Dim rangeRule As New GridItemFormatRule(extendedPrice)
            Dim rangeBarCondition As New  _
                FormatConditionGradientRangeBar(FormatConditionRangeGradientPredefinedType.BlueRed)
            rangeBarCondition.BarOptions.ShowBarOnly = True
            rangeRule.Condition = rangeBarCondition

            grid.FormatRules.AddRange(rangeRule)
        End Sub

        Private Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button1.Click
            Dim grid As GridDashboardItem = CType(dashboardViewer1.Dashboard.Items(0), GridDashboardItem)
            Dim rangeRule As GridItemFormatRule = grid.FormatRules(0)

            Dim rangeCondition As FormatConditionGradientRangeBar =
                CType(rangeRule.Condition, FormatConditionGradientRangeBar)
            rangeCondition.Generate(New BarStyleSettings(Color.PaleVioletRed),
                                    New BarStyleSettings(Color.PaleGreen), 9)
            Dim middleRange As RangeInfo = rangeCondition.RangeSet(4)
            middleRange.StyleSettings = New BarStyleSettings(Color.SkyBlue)

            rangeRule.Condition = rangeCondition
        End Sub
    End Class
End Namespace
See Also