Back to Devexpress

HeatmapAxis Class

corelibraries-devexpress-dot-xtracharts-dot-heatmap-587aa05f.md

latest8.7 KB
Original Source

HeatmapAxis Class

Contains settings for heatmap axes.

Namespace : DevExpress.XtraCharts.Heatmap

Assembly : DevExpress.XtraCharts.v25.2.dll

NuGet Package : DevExpress.Charts

Declaration

csharp
public class HeatmapAxis
vb
Public Class HeatmapAxis

The following members return HeatmapAxis objects:

LibraryRelated API Members
Cross-Platform Class LibraryHeatmapHitInfo.Axis
WinForms ControlsHeatmapControl.AxisX
HeatmapControl.AxisY

Remarks

The HeatmapAxis class contains options that allow you to configure appearance, access label and tickmark settings, and add titles to heatmap x- and y-axes.

Use the HeatmapControl.AxisX and HeatmapControl.AxisY properties to access heatmap axis settings.

csharp
using DevExpress.XtraCharts;
using DevExpress.XtraCharts.Heatmap;
using System;
using System.Drawing;
using System.Windows.Forms;
namespace HeatmapMatrixAdapterSample {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();

            HeatmapControl heatmap = new HeatmapControl();
            this.Controls.Add(heatmap);
            // ...
            // The Heatmap Control configuration is skipped.
            // ...
            heatmap.AxisX.Name = "axisX";
            heatmap.AxisY.Name = "axisY";
        }
    }
}
vb
Imports DevExpress.XtraCharts
Imports DevExpress.XtraCharts.Heatmap
Imports System.Windows.Forms

Namespace HeatmapMatrixAdapterSample
    Public Partial Class Form1
        Inherits Form

        Public Sub New()
            InitializeComponent()
            Dim heatmap As HeatmapControl = New HeatmapControl()
            Me.Controls.Add(heatmap)
            ' ...
            ' The Heatmap Control configuration is skipped.
            ' ...
            heatmap.AxisX.Name = "axisX"
            heatmap.AxisY.Name = "axisY"
        End Sub
    End Class
End Namespace

If you want to hide an axis, set its Visibility property to DefaultBoolean.False.

Enable the axis Reverse property to show axis labels and position cells in reversed order.

Configure Axis Labels

Use an axis’s Label property to access heatmap axis label settings. The example below configures label alignment, rotation, format pattern, and border settings:

csharp
AxisLabel2D label = heatmap.AxisX.Label;
label.Alignment = AxisLabelAlignment.Near;
label.Angle = 30;
label.BackColor = Color.LightGray;
label.Border.Visibility = DevExpress.Utils.DefaultBoolean.True;
label.Border.Thickness = 1;
label.Border.Color = Color.Gray;
label.TextPattern = "Division: {X}";
vb
Dim label As AxisLabel2D = heatmap.AxisX.Label
label.Alignment = AxisLabelAlignment.Near
label.Angle = 30
label.BackColor = Color.LightGray
label.Border.Visibility = DevExpress.Utils.DefaultBoolean.True
label.Border.Thickness = 1
label.Border.Color = Color.Gray
label.TextPattern = "Division: {X}"

Add Custom Axis Labels

You can display custom labels with default labels or in place of default labels. The adapter creates default labels based on cell arguments. Use the CustomLabels property to access an axis’s custom label collection. The following example displays a custom label on an x-axis:

csharp
heatmap.AxisX.CustomLabels.Add(new CustomAxisLabel { 
    AxisValue = "West", 
    Name = "Division: West", 
    BackColor = Color.LightGray });
heatmap.AxisX.LabelVisibilityMode = AxisLabelVisibilityMode.AutoGeneratedAndCustom;
vb
heatmap.AxisX.CustomLabels.Add(New CustomAxisLabel With {
    .AxisValue = "West",
    .Name = "Division: West",
    .BackColor = Color.LightGray
})
heatmap.AxisX.LabelVisibilityMode = AxisLabelVisibilityMode.AutoGeneratedAndCustom

Specify Grid Step

Use the GridSpacing property to specify how frequently the Heatmap Control should plot its tickmarks and labels. The GridSpacing value is automatically calculated until the AutoGrid property is enabled.

Customize Axis Tickmarks

Use an axis’s Tickmarks property to access tickmark appearance settings. Note that tickmarks are painted the same color as the axis to which they belong. The tickmark frequency depends on the axis GridSpacing property value.

csharp
HeatmapTickmarks tickmarks = heatmap.AxisX.Tickmarks;
tickmarks.CrossAxis = true;
tickmarks.Length = 10;
tickmarks.Thickness = 4;
tickmarks.Visible = true;
vb
Dim tickmarks As HeatmapTickmarks = heatmap.AxisX.Tickmarks
tickmarks.CrossAxis = True
tickmarks.Length = 10
tickmarks.Thickness = 4
tickmarks.Visible = True

Add Axis Title

You can accompany an axis with a single title that can be aligned along the axis. The Title property allows you to access title options. To show the title, enable the title’s Visibility property and specify the title Text.

csharp
heatmap.AxisY.Title.Visibility = DevExpress.Utils.DefaultBoolean.True;
heatmap.AxisY.Title.Text = "Category";
vb
heatmap.AxisY.Title.Visibility = DevExpress.Utils.DefaultBoolean.True
heatmap.AxisY.Title.Text = "Category"

Specify Axis Position

Define the Alignment property to specify axis position. The following values are available:

Near

The x-axis is positioned at the bottom of the chart, the y-axis – at the left.

Far

The x-axis is positioned at the top of the chart, the y-axis – at the right.

csharp
heatmap.AxisX.Alignment = HeatmapAxisLabelAlignment.Far;
heatmap.AxisY.Alignment = HeatmapAxisLabelAlignment.Far;
vb
heatmap.AxisX.Alignment = HeatmapAxisLabelAlignment.Far
heatmap.AxisY.Alignment = HeatmapAxisLabelAlignment.Far

Customize Axis Appearance

You can specify the axis color and thickness:

csharp
heatmap.AxisX.Color = Color.Gray;
heatmap.AxisX.Thickness = 4;
vb
heatmap.AxisX.Color = Color.Gray
heatmap.AxisX.Thickness = 4

Inheritance

Object HeatmapAxis

See Also

HeatmapAxis Members

DevExpress.XtraCharts.Heatmap Namespace