Skip to content
daisyBlazor

TreemapChart

A tree as nested rectangles, each leaf's area proportional to its value: storage by team and project, requests by region and service. D3 tiles the rectangles; the chart draws them in theme colours, one colour per top-level branch, with each parent's name in a header.
Hierarchy and networks
Cover · <TreemapChart>
StoragePlatform: 850; Product: 470; Data: 730Platform: 850PlatformData: 730DataProduct: 470ProductPlatform / Logs: 420LogsPlatform / Backups: 310BackupsPlatform / Images: 120ImagesData / Warehouse: 520WarehouseData / Snapshots: 210Snapsh…Product / Uploads: 380UploadsProduct / Exports: 90Exports

Examples

Basic

Root is a HierarchyNode: leaves carry a Value, parents add up their Children. Tiles show their name and value when they fit; hover any tile for its full path.

Storage by team and project (GB)
Storage by team and project (GB)Platform: 850; Product: 530; Data: 730; Support: 115Platform: 850Platform 850Data: 730Data 730Product: 530Product 530Support: 115Support 115Platform / Logs: 420Logs420Platform / Backups: 310Backups310Platform / Images: 120Images120Data / Warehouse: 520Warehouse520Data / Snapshots: 210Snapshots210Product / Uploads: 380Uploads380Product / Thumbnails: 90Thumbnails90Product / Exports: 60Exports60Support / Attachments: 70Attachments70Support / Recordings: 45Recordin…45
website/Examples/Charts/TreemapChartBasicExample.razor Source

Tiling

Tile chooses how each parent is cut (here SliceDice, which alternates rows and columns by level); ValueFormat sets the unit.

RequestsEurope: 1,290k; Americas: 960k; Asia: 400kEurope: 1,290kEurope 1,290kAmericas: 960kAmericas 960kAsia: 400kAsia 400kEurope / API: 840kAPI840kEurope / Auth: 260kAuth260kEurope / Search: 190kSearch190kAmericas / API: 620kAPI620kAmericas / Auth: 210kAuth210kAmericas / Search: 130kSearch130kAsia / API: 310kAPI310kAsia / Auth: 90kAuth90k
website/Examples/Charts/TreemapChartTileExample.razor Source

Strip

Tile="TreemapTile.Strip" fills rows in the children's order (largest first), each row taking the next tile while that keeps its tiles closer to square, so neighbours stay neighbours.

StorageLogs: 620 GB; Backups: 540 GB; Artifacts: 380 GB; Databases: 290 GB; Uploads: 210 GB; Search index: 150 GB; Cache: 90 GB; Metrics: 60 GBLogs: 620 GBLogs620 GBBackups: 540 GBBackups540 GBArtifacts: 380 GBArtifacts380 GBDatabases: 290 GBDatabases290 GBUploads: 210 GBUploads210 GBSearch index: 150 GBSearch index150 GBCache: 90 GBCache90 GBMetrics: 60 GBMetr…60 GB
website/Examples/Charts/TreemapChartStripExample.razor Source

Drill-down

Drilldown="true" makes every parent a button (click, or Tab then Enter): the chart re-roots on it at full size, colours stay those of its top-level branch, and the breadcrumb above goes back up. @bind-Focus sets or follows the drilled node as a path like "Platform/api" (a '/' inside a name is written "\/"); OnNodeClick reports any clicked node. Clicks need an interactive render mode; static rendering draws the Focus node.

Acme Cloud storage by team, service and data set (GB)
Acme Cloud storage by team, service and data set (GB)Platform: 810 GB; Product: 535 GB; Data: 760 GBPlatform: 810 GBPlatform 810 GBData: 760 GBData 760 GBProduct: 535 GBProduct 535 GBPlatform / api: 420 GBapi 420 GBPlatform / notifications: 230 GBnotifications 230 GBPlatform / auth: 160 GBauth 160 GBData / warehouse: 630 GBwarehouse 630 GBData / search: 130 GBsearch 130…Product / uploads: 470 GBuploads 470 GBProduct / exports: 65 GBexports 65 GBPlatform / api / Request logs: 260 GBRequest logs260 GBPlatform / api / Audit trail: 120 GBAudit trail120 GBPlatform / api / Cache dumps: 40 GBCache dumps40 GBPlatform / notifications / Delivery logs: 150 GBDelivery l…150 GBPlatform / notifications / Outbox: 80 GBOutb…80 GBPlatform / auth / Sessions: 90 GBSessions90 GBPlatform / auth / Sign-in logs: 70 GBSign-in logs70 GBData / warehouse / Events: 420 GBEvents420 GBData / warehouse / Snapshots: 210 GBSnapshots210 GBData / search / Indexes: 130 GBIndexes130 GBProduct / uploads / Originals: 380 GBOriginals380 GBProduct / uploads / Thumbnails: 90 GBThumbnails90 GBProduct / exports / CSV: 40 GBCSVProduct / exports / PDF: 25 GBPDF

Focus: (whole tree)

website/Examples/Charts/TreemapChartDrilldownExample.razor Source

Playground

Storage by team and project (GB)
Storage by team and project (GB)Platform: 850; Product: 530; Data: 730; Support: 115Platform: 850Platform 850Data: 730Data 730Product: 530Product 530Support: 115Support 115Platform / Logs: 420Logs420Platform / Backups: 310Backups310Platform / Images: 120Images120Data / Warehouse: 520Warehouse520Data / Snapshots: 210Snapshots210Product / Uploads: 380Uploads380Product / Thumbnails: 90Thumbnails90Product / Exports: 60Exports60Support / Attachments: 70Attachments70Support / Recordings: 45Recordi…45
Tile TreemapTile
<TreemapChart
              Title="Storage by team and project (GB)"
              Root="@_storage" />

@code {
    private readonly HierarchyNode _storage = new("Storage", Children:
    [
        new("Platform", Children: [new("Logs", 420), new("Backups", 310), new("Images", 120)]),
        new("Product", Children: [new("Uploads", 380), new("Thumbnails", 90), new("Exports", 60)]),
        new("Data", Children: [new("Warehouse", 520), new("Snapshots", 210)]),
        new("Support", Children: [new("Attachments", 70), new("Recordings", 45)]),
    ]);
}

API

<TreemapChart>

DaisyBlazor.Charts

Parameters

  • AspectRatio double
    = 1.78

    Width divided by height. The chart keeps this shape at any width; its text keeps its size.

  • Drilldown bool
    = false

    Click (or Enter on) a node with children to show only that branch, at full size; a leaf below the first level opens its parent, so a treemap whose leaves cover their parents still drills. A breadcrumb above the chart goes back up. Needs an interactive render mode: under static rendering the chart shows Focus (or the whole tree) with no buttons.

  • Focus string
    = null

    The node drawn as the root, as the names below the root joined by '/', e.g. "Platform/Logs"; null for the whole tree. A '/' inside a name is written "\/" and a backslash "\\", so the node "A / B" under "CI/CD" is "CI\/CD/A \/ B" (FocusChanged reports paths the same way). Bind it with @bind-Focus to set or follow the drilled node. An unknown path shows the whole tree and a leaf shows its parent. Applies under static rendering too.

  • GroupColors IReadOnlyDictionary<string, string>
    = null

    Optional colour per top-level branch name (any CSS colour); other branches cycle through the theme palette.

  • Padding double
    = 2

    Gap between sibling tiles and inside each parent frame, in chart units.

  • Root HierarchyNode
    = null

    The tree to draw. Leaves are sized by Value; a parent is the sum of its children. The root itself is not drawn.

  • RowHeight double?
    = null

    Height of each row in px, for a chart that lays its categories out as rows (horizontal bars, a Gantt's lanes, a heatmap's rows…): its height then follows its number of rows instead of AspectRatio, so a long list keeps readable rows at any width. A chart, or an orientation, without rows ignores it.

  • ShowTitle bool
    = true

    Draw Title as a visible heading above the chart (the default); false keeps it only as the chart's accessible name, for a chart inside a card that already has a heading.

  • ShowValues bool
    = true

    Print each tile's value under its name, and each parent's total in its header, when they fit.

  • Tile TreemapTile
    = TreemapTile.Squarify

    How each parent is cut into tiles.

  • Title string
    = null

    Optional heading rendered above the chart; it is also the chart's accessible name.

  • ValueFormat string
    = "{0:#,0.##}"

    Format string for values in labels and tooltips, e.g. "{0:N0} GB".

  • Width string
    = "100%"

    CSS width of the chart wrapper.

  • Class string
    = null

    Additional CSS classes merged onto the w-full wrapper.

  • Style string
    = null

    Inline styles appended after the width on the wrapper.

Events

  • FocusChanged EventCallback<string>

    Raised with the new Focus when a click or the breadcrumb moves it (interactive render modes only).

  • OnNodeClick EventCallback<HierarchyNode>

    Raised with the clicked node of Root, leaves included, when set; nodes become buttons even without Drilldown. Needs an interactive render mode.

Something went wrong while running the docs. Reload