Unit Treemap

Description

Squarified treemap component for the VCL.

This unit implements TTreeMap, a TGraphicControl descendant that renders a set of weighted items as a squarified treemap: nested rectangles whose areas are proportional to each item's TTreeMapItem.Size and whose aspect ratios are kept as close to square as possible for readability.

The public model consists of three cooperating types:

Custom rendering is possible through TTreeMap.OnDrawItem; when no handler is assigned an internal default painter is used.

Overview

Classes, Interfaces, Objects and Records

Name Description
Class TTreeMap A control that displays weighted items as a squarified treemap.
Class TTreeMapContainer An owning, size-sorted list of TTreeMapItem instances.
Class TTreeMapItem A single node in a treemap: a weighted, captioned rectangle.

Functions and Procedures

procedure Register;

Types

TTreeMapItemState = (...);
TTreeMapItemStates = set of TTreeMapItemState;
TOnDrawTreeMapItemEvent = procedure( Sender: TObject; Canvas: TCanvas; Item: TTreeMapItem; State: TTreeMapItemStates; var Area: TRect) of object;
TOnTreeMapItemClickEvent = procedure( Sender: TObject; Item: TTreeMapItem; Button: TMouseButton; State: TTreeMapItemStates ) of object;

Description

Functions and Procedures

procedure Register;

Registers TTreeMap on the "Fasko" component palette page.

Types

TTreeMapItemState = (...);

State flags describing how a TTreeMapItem is to be painted. They are passed as a set to draw handlers (TOnDrawTreeMapItemEvent) and click handlers (TOnTreeMapItemClickEvent).

Values
  • tmisHighlight: The mouse pointer is currently hovering over the item.
  • tmisSelected: The item is selected (see TTreeMap.SetSelected).
  • tmisLast: Internal: marks the last item included in the current layout.
TTreeMapItemStates = set of TTreeMapItemState;

A set of TTreeMapItemState flags describing an item's paint state.

TOnDrawTreeMapItemEvent = procedure( Sender: TObject; Canvas: TCanvas; Item: TTreeMapItem; State: TTreeMapItemStates; var Area: TRect) of object;

Custom-draw event for a single treemap item.

Assign a handler to TTreeMap.OnDrawItem to take over painting of items.

Parameters
Sender
The TTreeMap control requesting the draw.
Canvas
The canvas to paint onto.
Item
The item to be drawn.
State
The item's current paint state.
Area
The rectangle the item must be drawn into. This is a var parameter: a handler may shrink it – for example to a small title bar – and return the remaining area, into which the item's children are then laid out and drawn.
TOnTreeMapItemClickEvent = procedure( Sender: TObject; Item: TTreeMapItem; Button: TMouseButton; State: TTreeMapItemStates ) of object;

Click and double-click event for a treemap item. Used by both TTreeMap.OnClickItem and TTreeMap.OnDblClickItem.

Parameters
Sender
The TTreeMap control that raised the event.
Item
The item under the mouse pointer.
Button
The mouse button involved.
State
The item's current paint state.

Author

Created

26.07.2026

Last Modified

26.07.2026


Generated by PasDoc 1.0.4.