demo D266
Parallel coordinates in Angular
One line per row across several axes at once, coloured by group to surface a pattern
type: 'parallel', columns, colourBy
This draws one line per row across several axes at once, coloured by group, so a pattern across many measures surfaces. It shows how records with many attributes cluster or differ, which a pair of axes cannot.
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-parallel'; // opt in to the parallel 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',
columns: [
{ field: 'symbol', title: 'Symbol' },
{ field: 'desk', title: 'Desk', filter: { type: 'set' } },
{ field: 'price', title: 'Price', type: 'number', format: { decimals: 4 } },
{ field: 'bid', title: 'Bid', type: 'number', format: { decimals: 4 } },
{ field: 'ask', title: 'Ask', type: 'number', format: { decimals: 4 } },
{ field: 'volume', title: 'Volume', type: 'number', format: { notation: 'compact' } },
{ field: 'notional', title: 'Notional', type: 'number', format: { style: 'currency', currency: 'USD' }, total: 'sum' },
],
rows: [/* instruments: symbol, desk, price, bid, ask, volume, notional */],
};
ngAfterViewInit() {
// columns draws one axis per measure and one line per row; colourBy
// tints the lines by a category, so a pattern per desk shows.
createChart({ grid: this.gridRef.grid, container: '#chart', type: 'parallel', columns: ['price', 'bid', 'ask', 'volume'], colourBy: 'desk', title: 'Instruments across four measures' });
}
}
bootstrapApplication(AppComponent, {
providers: [provideLattice({ createGrid })],
});