HeatmapHitInfo.InLegend Property
Indicates whether the test point is within the heatmap legend.
Namespace: DevExpress.Xpf.Charts.Heatmap
Assembly: DevExpress.Xpf.Charts.v24.2.dll
NuGet Package: DevExpress.Wpf.Charts
Declaration
Property Value
Type | Description |
---|---|
Boolean | true if the test point is within the legend; otherwise, false. |
Remarks
Use the InLegend
property to check whether the test point is located within the heatmap legend.
To obtain the legend instance located under the test point, use the Legend property.
Example
The following example shows how to determine what a heatmap element is in a test point and how to collect information related to this element.
Call the HeatmapControl.CalcHitInfo method to obtain information about a specific point within the Heatmap Control. This method returns a HeatmapHitInfo object that contains information related to heatmap elements positioned in the test point.
<Window xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
xmlns:dxc="http://schemas.devexpress.com/winfx/2008/xaml/charts"
xmlns:dxh="http://schemas.devexpress.com/winfx/2008/xaml/heatmap"
x:Class="HeatmapChart.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:HeatmapChart"
xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
mc:Ignorable="d"
dx:ThemeManager.ThemeName="Office2019Colorful"
Title="MainWindow" Height="410" Width="728">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="130"/>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<dxe:TextEdit Grid.Column="0" x:Name="textEdit" TextWrapping="Wrap"
VerticalContentAlignment="Top" BorderBrush="Transparent"/>
<dxh:HeatmapControl x:Name="heatmapControl"
Grid.Column="1"
ToolTipEnabled="True" Margin="10"
MouseMove="heatmapControl_MouseMove">
<dxh:HeatmapControl.DataContext>
<local:MatrixHeatmapViewModel />
</dxh:HeatmapControl.DataContext>
<dxh:HeatmapControl.DataAdapter>
<dxh:HeatmapMatrixAdapter XArguments="{Binding XArguments}"
YArguments="{Binding YArguments}"
Values="{Binding Values}" />
</dxh:HeatmapControl.DataAdapter>
<dxh:HeatmapControl.ColorProvider>
<!--...-->
</dxh:HeatmapControl.ColorProvider>
<dxh:HeatmapControl.Legend>
<dxh:HeatmapLegend Margin="0, 0, 4, 10" Visible="True">
<dxh:HeatmapLegend.Title>
<dxc:LegendTitle Content="Revenue" />
</dxh:HeatmapLegend.Title>
</dxh:HeatmapLegend>
</dxh:HeatmapControl.Legend>
<dxh:HeatmapControl.AxisX>
<dxh:HeatmapAxis x:Name="xAxis" Reverse="True" Alignment="Near"
AutoGrid="False" GridSpacing="1">
<dxh:HeatmapAxis.Title>
<dxc:AxisTitle Content="Region" Visibility="Visible"/>
</dxh:HeatmapAxis.Title>
<dxh:HeatmapAxis.Label>
<dxc:AxisLabel x:Name="xAxisLabel"/>
</dxh:HeatmapAxis.Label>
</dxh:HeatmapAxis>
</dxh:HeatmapControl.AxisX>
<dxh:HeatmapControl.AxisY>
<dxh:HeatmapAxis x:Name="yAxis" Reverse="True" Alignment="Near">
<dxh:HeatmapAxis.Title>
<dxc:AxisTitle Content="Product Category" Visibility="Visible"/>
</dxh:HeatmapAxis.Title>
<dxh:HeatmapAxis.Label>
<dxc:AxisLabel x:Name="yAxisLabel"/>
</dxh:HeatmapAxis.Label>
</dxh:HeatmapAxis>
</dxh:HeatmapControl.AxisY>
<dxh:HeatmapControl.Label>
<dxh:HeatmapLabel Foreground="Black"
Background="#70ffffff"
Padding="2"
TextOrientation="Horizontal"
TextPattern="${V}M"/>
</dxh:HeatmapControl.Label>
</dxh:HeatmapControl>
</Grid>
</Window>
using DevExpress.Xpf.Charts;
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Input;
namespace HeatmapChart {
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
}
private void heatmapControl_MouseMove(object sender, MouseEventArgs e) {
// Obtain hit information under the test point.
HeatmapHitInfo hitInfo = heatmapControl.CalcHitInfo(e.GetPosition(heatmapControl));
StringBuilder builder = new StringBuilder();
if (hitInfo.InAxis) builder.AppendLine($"In axis:");
if (hitInfo.AxisLabel != null)
builder.AppendLine($"Label: {hitInfo.AxisLabel.Name}");
if (hitInfo.AxisTitle != null)
builder.AppendLine($"Axis title: {hitInfo.AxisTitle.Content}");
if (hitInfo.InHeatmapCell)
builder.AppendLine($"In cell:{Environment.NewLine}X ({hitInfo.HeatmapCell.XArgument}),{Environment.NewLine}Y ({hitInfo.HeatmapCell.YArgument})");
if (hitInfo.InLegend)
builder.AppendLine($"In legend");
// Show hit-testing results.
if (builder.Length > 0)
textEdit.Text = string.Format($"Hit-testing results:{Environment.NewLine}{builder}");
else
textEdit.Text = "Move the mouse pointer over the heatmap to see information on hovered heatmap elements.";
}
}
public class MatrixHeatmapViewModel {
public string[] XArguments { get; set; }
public string[] YArguments { get; set; }
public double[,] Values { get; set; }
public MatrixHeatmapViewModel() {
XArguments = new string[] { "North", "South", "West", "East", "Central" };
YArguments = new string[] { "Accessories", "Bikes", "Clothing", "Components" };
Values = new double[,] {
{ 214.3, 530.1, 630.2, 854.4, 313.4 },
{ 321.3, 514.4, 281.3, 533.4, 541.9 },
{ 604.3, 429.1, 632.6, 438.4, 265.4 },
{ 485.3, 544.7, 740.3, 661.4, 516.6 }
};
}
}
}