TreeMap Component — sgcHTML | eSeGeCe

TreeMap

TsgcHTMLComponent_TreeMap — render a squarified treemap as a self-contained, server-generated inline SVG, no charting library required, in Delphi, C++ Builder and .NET.

TsgcHTMLComponent_TreeMap

Add items with a label and a value (or bind a dataset), pick a colour scheme, then read the HTML property.

Component class

TsgcHTMLComponent_TreeMap

Renders

Self-contained inline SVG, squarified layout

Languages

Delphi, C++ Builder, .NET

Add items, render it

Call AddItem for each rectangle, choose a ColorScheme, then read HTML. The layout is computed server-side and needs no client-side library.

uses
  sgcHTML_Component_TreeMap;

var
  oTreeMap: TsgcHTMLComponent_TreeMap;
begin
  oTreeMap := TsgcHTMLComponent_TreeMap.Create(nil);
  try
    oTreeMap.Width := 640;
    oTreeMap.Height := 360;
    oTreeMap.ColorScheme := tmCool;
    oTreeMap.ShowValues := True;

    oTreeMap.AddItem('Engineering', 420000);
    oTreeMap.AddItem('Sales', 260000);
    oTreeMap.AddItem('Marketing', 140000);
    oTreeMap.AddItem('Support', 90000, '#20c997');   // explicit colour overrides the scheme

    WebModule.Response := oTreeMap.HTML;   // <svg> squarified rectangles, no client-side library
  finally
    oTreeMap.Free;
  end;
end;

// Or bind it straight to a dataset:
oTreeMap.LoadFromDataSet(qryBudget, 'Department', 'Amount');

// One-shot helper, no instance to manage:
Response := TsgcHTMLComponent_TreeMap.Build(['Engineering', 'Sales'], [420000, 260000]);
// includes: sgcHTML_Component_TreeMap.hpp

TsgcHTMLComponent_TreeMap *oTreeMap = new TsgcHTMLComponent_TreeMap(NULL);
try
{
  oTreeMap->Width = 640;
  oTreeMap->Height = 360;
  oTreeMap->ColorScheme = tmCool;
  oTreeMap->ShowValues = true;

  oTreeMap->AddItem("Engineering", 420000);
  oTreeMap->AddItem("Sales", 260000);
  oTreeMap->AddItem("Marketing", 140000);
  oTreeMap->AddItem("Support", 90000, "#20c997");   // explicit colour overrides the scheme

  String html = oTreeMap->HTML;   // <svg> squarified rectangles, no client-side library
}
__finally
{
  delete oTreeMap;
}
using esegece.sgcWebSockets;

var treeMap = new TsgcHTMLComponent_TreeMap();
treeMap.Width = 640;
treeMap.Height = 360;
treeMap.ColorScheme = TsgcHTMLTreeMapScheme.tmCool;
treeMap.ShowValues = true;

treeMap.AddItem("Engineering", 420000);
treeMap.AddItem("Sales", 260000);
treeMap.AddItem("Marketing", 140000);
treeMap.AddItem("Support", 90000, "#20c997");   // explicit colour overrides the scheme

string html = treeMap.HTML;   // <svg> squarified rectangles, no client-side library

// One-shot helper, no instance to manage:
string quick = TsgcHTMLComponent_TreeMap.Build(new[] { "Engineering", "Sales" }, new[] { 420000d, 260000d });

Key properties & methods

The members you reach for most often.

Items / AddItem

AddItem(aLabel, aValue, aColor) appends a leaf rectangle; an explicit aColor overrides the active ColorScheme.

Hierarchy

Items support a two-level treemap: set ID / ParentID on parent and child items to nest child rectangles inside their faded parent.

Dataset binding

LoadFromDataSet(aDataSet, aLabelField, aValueField) loads one flat item per row.

One-shot helper

The class function Build(aLabels, aValues) renders a flat treemap straight to a string, with no component instance to manage.

Sizing & palette

Width, Height, Padding and ColorScheme (default/blue/green/warm/cool/gray) control the canvas and the auto-assigned rectangle colours.

Labels

ShowLabels, ShowValues, MinLabelSize and FontSize decide when and how a rectangle's caption is drawn; HTML returns the finished inline <svg>.

Keep exploring

Online HelpFull API reference and usage guide for this component.
All sgcHTML ComponentsBrowse the full feature matrix of 80+ components.
Download Free TrialThe 30-day trial ships the 60.HTML demo projects.
PricingSingle, Team and Site licenses with full source code.
Best value: All-AccessEvery eSeGeCe product, Premium Support included, from €1,059/year.
See All-Access pricing

Ready to Get Started?

Download the free trial and start building web UIs in Delphi, C++ Builder and .NET.