How do we enable the selection border on a RadHeatMap with custom HeatMapDefinition?

1 Answer 13 Views
HeatMap
Martin
Top achievements
Rank 1
Martin asked on 08 Apr 2024, 02:22 PM

Hello,

we currently use a HeatMap for our C# WPF (.NET Core) project to visualize data with a custom HeatMapDefinition.
Now we want the HeatMap to show a selection border for the selected cell, but this is not working for us as no selection border is shown.

The problem is easily reproducible in the xaml-sdk (with the CustomHeatMapSourceAndDefiniton project).
Just change in the MainWindow.xaml the RadHeatMap like this:
        <telerik:RadHeatMap x:Name="heatmap"
                            SelectionMode="SingleDataItem"
                            SelectedCellBorderColor="Magenta"
                            SelectedCellBorderThickness="5">
...

And limit the GetData parameters in MainWindow.xaml.cs to something like:
CustomHeatMapItem[,] data = this.GetData(20, 30);

According to the documentation, setting SelectionMode, SelectedCellBorderColor and SelectedCellBorderThickness like this should be sufficient, but in our test no border was drawn.

We tested in our project with a CategoricalDefinition and there the selection does work.

Looking into the source code of the HeatMap, the HeatMapColorGrid should be responsible to draw the selection border in different combinations (with and without hover, etc).
In the method RedrawAllCells() for example:
this.DrawSelectedCell(rowIndex, columnIndex, intColor);

However those calls all seem gated by if-checks with a call to this.Definition.IsCellSelected(rowIndex, columnIndex).

Which calls the method IsCellSelected from the current definition casted as HeatMapDefinition.
This method in the HeatMapDefinition always returns false and is internal, so we cannot override it within our derived custom HeatMapDefinition (as opposed to e.g. CategoricalDefinition, which overrides it).

So the question is, how do we get the HeatMap to draw the selection border, if we cannot tell it that the cell is selected?
Or did we miss something?

1 Answer, 1 is accepted

Sort by
1
Accepted
Martin Ivanov
Telerik team
answered on 09 Apr 2024, 01:46 PM

Hello Martin,

One way to achieve your requirement is to use the SelectedItems collection of the HeatMapDefinition in the GetColor method override.

   protected override int GetColor(int rowIndex, int columnIndex)
   {
       if(SelectedItems.Contains(this.source.GetDataItem(rowIndex, columnIndex)))
       {
           return ToColorInt(Colors.Red);
       }
       int color = ToColorInt(this.source.GetColor(rowIndex, columnIndex));
       return color;
   }

Keep in mind that this will affect only the background, but not the border.

I also added a new item in our feedback portal to make the IsCellSelected and the related methods "protected internal" which will allow the developer to override them and decide if the cell is selected or not. In this regard, you can find your Telerik points updated.

Regards,
Martin Ivanov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
HeatMap
Asked by
Martin
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or