Back to Devexpress

HeatmapRangeColorProvider.ApproximateColors Property

corelibraries-devexpress-dot-xtracharts-dot-heatmap-dot-heatmaprangecolorprovider-2b313efb.md

latest9.5 KB
Original Source

HeatmapRangeColorProvider.ApproximateColors Property

Specifies whether to approximate colors.

Namespace : DevExpress.XtraCharts.Heatmap

Assembly : DevExpress.XtraCharts.v25.2.dll

NuGet Package : DevExpress.Charts

Declaration

csharp
public bool ApproximateColors { get; set; }
vb
Public Property ApproximateColors As Boolean

Property Value

TypeDescription
Boolean

true if an approximation algorithm is applied to colors; otherwise, false.

|

Remarks

The ApproximateColors property allows you to apply smooth transition between colors:

ApproximateColors = trueApproximateColors = false

Example

This example shows how to use arrays of string and numeric values to create a heatmap:

Follow the steps below to create a heatmap:

  1. Add the HeatmapControl to the Form.
  2. Create a HeatmapMatrixAdapter object and assign it to the HeatmapControl.DataAdapter property.
  3. Use the adapter’s XArguments and YArguments properties to populate the heatmap with x- and y-arguments that are displayed along x- and y-axes.
  4. Assign a two-dimensional array of double values to the adapter’s Values property.
  5. Create a HeatmapRangeColorProvider object and assign it to the heatmap’s ColorProvider property. The HeatmapRangeColorProvider paints cells based on the value range to which the cell value belongs.
  6. Add a HeatmapTitle to the heatmap’s Titles collection. Specify the title’s Text property.
  7. Use the heatmap’s Label property to configure cell label options. This example shows how to configure label text format.

View Example

csharp
using DevExpress.XtraCharts;
using DevExpress.XtraCharts.Heatmap;
using System.Drawing;
using System.Windows.Forms;

namespace HeatmapMatrixData {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();

            HeatmapMatrixAdapter dataAdapter = new HeatmapMatrixAdapter();
            dataAdapter.XArguments = new string[] { "North", "South", "West", "East", "Central" };
            dataAdapter.YArguments = new string[] { "Components", "Clothing", "Bikes", "Accessories" };
            dataAdapter.Values = new double[,] {
                { 21.3, 50.1, 63.2, 64.4, 33.4 },
                { 32.3, 54.4, 81.3, 53.4, 54.9 },
                { 60.3, 49.1, 42.6, 48.4, 65.4 },
                { 45.3, 54.7, 70.3, 66.4, 56.6 }
            };
            heatmap.DataAdapter = dataAdapter;

            Palette palette = new Palette("Custom") {
                Color.White,
                Color.SkyBlue,
                Color.DarkBlue
            };

            HeatmapRangeColorProvider colorProvider = new HeatmapRangeColorProvider() {
                Palette = palette,
                ApproximateColors = true
            };
            colorProvider.RangeStops.Add(new HeatmapRangeStop(0, HeatmapRangeStopType.Percentage));
            colorProvider.RangeStops.Add(new HeatmapRangeStop(20, HeatmapRangeStopType.Absolute));
            colorProvider.RangeStops.Add(new HeatmapRangeStop(40, HeatmapRangeStopType.Absolute));
            colorProvider.RangeStops.Add(new HeatmapRangeStop(60, HeatmapRangeStopType.Absolute));
            colorProvider.RangeStops.Add(new HeatmapRangeStop(90, HeatmapRangeStopType.Absolute));
            colorProvider.RangeStops.Add(new HeatmapRangeStop(1, HeatmapRangeStopType.Percentage));

            heatmap.ColorProvider = colorProvider;

            heatmap.Titles.Add(new HeatmapTitle { Text = "Sales by Categories" });

            heatmap.Label.Visible = true;
            heatmap.Label.Pattern = "{V}";
        }
    }
}
vb
Imports DevExpress.XtraCharts
Imports DevExpress.XtraCharts.Heatmap
Imports System.Drawing
Imports System.Windows.Forms

Namespace HeatmapMatrixData

    Public Partial Class Form1
        Inherits System.Windows.Forms.Form

        Public Sub New()
            Me.InitializeComponent()
            Dim dataAdapter As DevExpress.XtraCharts.Heatmap.HeatmapMatrixAdapter = New DevExpress.XtraCharts.Heatmap.HeatmapMatrixAdapter()
            dataAdapter.XArguments = New String() {"North", "South", "West", "East", "Central"}
            dataAdapter.YArguments = New String() {"Components", "Clothing", "Bikes", "Accessories"}
            dataAdapter.Values = New Double(,) {{21.3, 50.1, 63.2, 64.4, 33.4}, {32.3, 54.4, 81.3, 53.4, 54.9}, {60.3, 49.1, 42.6, 48.4, 65.4}, {45.3, 54.7, 70.3, 66.4, 56.6}}
            Me.heatmap.DataAdapter = dataAdapter
            Dim palette As DevExpress.XtraCharts.Palette = New DevExpress.XtraCharts.Palette("Custom") From {System.Drawing.Color.White, System.Drawing.Color.SkyBlue, System.Drawing.Color.DarkBlue}
            Dim colorProvider As DevExpress.XtraCharts.Heatmap.HeatmapRangeColorProvider = New DevExpress.XtraCharts.Heatmap.HeatmapRangeColorProvider() With {.Palette = palette, .ApproximateColors = True}
            colorProvider.RangeStops.Add(New DevExpress.XtraCharts.Heatmap.HeatmapRangeStop(0, DevExpress.XtraCharts.Heatmap.HeatmapRangeStopType.Percentage))
            colorProvider.RangeStops.Add(New DevExpress.XtraCharts.Heatmap.HeatmapRangeStop(20, DevExpress.XtraCharts.Heatmap.HeatmapRangeStopType.Absolute))
            colorProvider.RangeStops.Add(New DevExpress.XtraCharts.Heatmap.HeatmapRangeStop(40, DevExpress.XtraCharts.Heatmap.HeatmapRangeStopType.Absolute))
            colorProvider.RangeStops.Add(New DevExpress.XtraCharts.Heatmap.HeatmapRangeStop(60, DevExpress.XtraCharts.Heatmap.HeatmapRangeStopType.Absolute))
            colorProvider.RangeStops.Add(New DevExpress.XtraCharts.Heatmap.HeatmapRangeStop(90, DevExpress.XtraCharts.Heatmap.HeatmapRangeStopType.Absolute))
            colorProvider.RangeStops.Add(New DevExpress.XtraCharts.Heatmap.HeatmapRangeStop(1, DevExpress.XtraCharts.Heatmap.HeatmapRangeStopType.Percentage))
            Me.heatmap.ColorProvider = colorProvider
            Me.heatmap.Titles.Add(New DevExpress.XtraCharts.Heatmap.HeatmapTitle With {.Text = "Sales by Categories"})
            Me.heatmap.Label.Visible = True
            Me.heatmap.Label.Pattern = "{V}"
        End Sub
    End Class
End Namespace

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the ApproximateColors property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-dashboard-custom-items-extension/CS/CustomItemExtension/CustomItems/Heatmap/HeatmapItemControlProvider.cs#L85

csharp
HeatmapRangeColorProvider provider = new HeatmapRangeColorProvider();
provider.ApproximateColors = true;
List<double> rangeStops = new List<double>();

winforms-dashboard-custom-items-extension/VB/CustomItemExtension/CustomItems/Heatmap/HeatmapItemControlProvider.vb#L88

vb
Dim provider As New HeatmapRangeColorProvider()
provider.ApproximateColors = True
Dim rangeStops As New List(Of Double)()

See Also

HeatmapRangeColorProvider Class

HeatmapRangeColorProvider Members

DevExpress.XtraCharts.Heatmap Namespace