Lattice Grid Buy a licence

demo D251

Bump chart in Angular

Watch a ranking change from one period to the next, where a crossing is a change of place

type: 'bump', x, series, y

This draws a bump chart of a ranking changing from one period to the next, where a crossing line is a change of place. It makes shifts in position over time obvious, so who overtook whom reads directly.

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-bump';  // opt in to the bump 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:320px;margin-top:14px"></lattice-grid>',
})
export class AppComponent implements AfterViewInit {
  @ViewChild(LatticeGridComponent) gridRef!: LatticeGridComponent;

  grid = {
    rowKey: 'id',
    columns: [
      { field: 'team', title: 'Team', filter: { type: 'set' } },
      { field: 'quarter', title: 'Quarter', filter: { type: 'set' } },
      { field: 'revenue', title: 'Revenue', type: 'number', total: 'sum' },
    ],
    rows: [/* one team per quarter: team, quarter, revenue */],
  };

  ngAfterViewInit() {
    createChart({ grid: this.gridRef.grid, container: '#chart', type: 'bump', x: 'quarter', series: 'team', y: 'revenue', title: 'Rank by quarter' });
  }
}

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