Lattice Grid Buy a licence

demo D259

Icicle in Angular

A hierarchy as nested bars, each band as wide as the share of the total beneath it

type: 'icicle', y

This draws a hierarchy as nested bars, each band as wide as the share of the total beneath it. It shows how a total breaks down through levels, so where the weight sits in a tree reads as width.

Building…
Loading a live grid…

This is the Angular version. A standalone component takes the whole configuration through one config input, surfaces grid events as outputs, and exposes the live grid on a getter for anything the inputs do not cover.

The configuration

import { Component, ViewChild, AfterViewInit } from '@angular/core';
import { bootstrapApplication } from '@angular/platform-browser';
import { createGrid } from '@toclocoinc/lattice-grid';
import '@toclocoinc/lattice-grid/css';
import { createChart } from '@toclocoinc/lattice-grid/modules/charts';
import '@toclocoinc/lattice-grid/modules/chart-icicle';  // opt in to the icicle type
import { LatticeGridComponent, provideLattice } from '@toclocoinc/lattice-grid/angular';

@Component({
  selector: 'app-root',
  standalone: true,
  imports: [LatticeGridComponent],
  template:
    '<div id="chart" style="height:340px"></div>' +
    '<lattice-grid [config]="grid" style="display:block;height:340px;margin-top:14px"></lattice-grid>',
})
export class AppComponent implements AfterViewInit {
  @ViewChild(LatticeGridComponent) gridRef!: LatticeGridComponent;

  grid = {
    rowKey: 'id',
    group: { expanded: false },  // the icicle reads the grid's group tree
    columns: [
      { field: 'region', title: 'Region', group: { enabled: true, index: 0 } },
      { field: 'status', title: 'Status', group: { enabled: true, index: 1 } },
      { field: 'charge', title: 'Monthly charge', type: 'number',
        format: { style: 'currency', currency: 'GBP' }, total: 'sum' },
    ],
    rows: [/* circuits: region, status, charge */],
  };

  ngAfterViewInit() {
    createChart({ grid: this.gridRef.grid, container: '#chart', type: 'icicle', y: 'charge', title: 'Charge by region, then status' });
  }
}

bootstrapApplication(AppComponent, {
  providers: [provideLattice({ createGrid })],
});