New to Telerik UI for WinForms? Download free 30-day trial

Legend

RadTreeMap has built-in support for a legend – descriptions about the treemap data on the plot. The ShowLegend property of RadTreeMap controls whether the legend is visible or not. The default value is false. The legend supports showing a legend title, which text can be set via the LegendTitle property of the TreeMapDataItemGroup. A sample approach to populate RadTreeMap with data is demonstrated in the Unbound Mode article >> Populating with Data at Run Time section.

RadTreeMap's legend

winforms-treemap-legend 001

this.radTreeMap1.ShowLegend = true;
this.radTreeMap1.LegendPosition = RadPosition.Right;
this.radTreeMap1.LegendTitle = "Continents";
this.radTreeMap1.LegendOrientation = Orientation.Vertical;


Me.radTreeMap1.ShowLegend = True
Me.radTreeMap1.LegendPosition = RadPosition.Right
Me.radTreeMap1.LegendTitle = "Continents"
Me.radTreeMap1.LegendOrientation = Orientation.Vertical

The TreeMapElement.LegendElement.VisualItemCreating event allows you to create custom legend elements or customize the default ones:

Customize the default LegendItemElement

Font f = new Font("Arial", 10f, FontStyle.Bold);
private void LegendElement_VisualItemCreating(object sender,
    Telerik.WinControls.UI.TreeMap.LegendItemElementCreatingEventArgs e)
{
    Telerik.WinControls.UI.TreeMap.LegendItemElement legendElement =
        new Telerik.WinControls.UI.TreeMap.LegendItemElement(e.GroupItem);
    legendElement.Font = f;
    legendElement.TitleElement.ForeColor = Color.Red;
    legendElement.MarkerElement.DrawBorder = true;
    legendElement.MarkerElement.BorderBoxStyle = BorderBoxStyle.SingleBorder;
    legendElement.MarkerElement.BorderColor = Color.Red;
    legendElement.MarkerElement.BorderWidth = 1;
    e.ItemElement = legendElement;
}


Private f As Font = New Font("Arial", 10.0F, FontStyle.Bold)
Private Sub LegendElement_VisualItemCreating(ByVal sender As Object,
                  ByVal e As Telerik.WinControls.UI.TreeMap.LegendItemElementCreatingEventArgs)
    Dim legendElement As Telerik.WinControls.UI.TreeMap.LegendItemElement =
        New Telerik.WinControls.UI.TreeMap.LegendItemElement(e.GroupItem)
    legendElement.Font = f
    legendElement.TitleElement.ForeColor = Color.Red
    legendElement.MarkerElement.DrawBorder = True
    legendElement.MarkerElement.BorderBoxStyle = BorderBoxStyle.SingleBorder
    legendElement.MarkerElement.BorderColor = Color.Red
    legendElement.MarkerElement.BorderWidth = 1
    e.ItemElement = legendElement
End Sub

winforms-treemap-legend 002

See Also

In this article