demo D179
Statistics in the totals row in Angular
Median, percentiles, deviation and spread, each over the filtered rows
total: 'median' · 'p95' · 'stddev'
This grid puts statistics in the totals row, median, percentiles, standard deviation and spread, each computed over the filtered rows. It gives a footer that summarises the shape of a column, not just its sum, and follows the filter as it changes.
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 } from '@angular/core';
import { bootstrapApplication } from '@angular/platform-browser';
import { createGrid } from '@toclocoinc/lattice-grid';
import '@toclocoinc/lattice-grid/css';
import { LatticeGridComponent, provideLattice } from '@toclocoinc/lattice-grid/angular';
const columns = [
{ field: 'symbol', title: 'Symbol', layout: { pin: 'start', width: 150 } },
{ field: 'desk', title: 'Desk', filter: { type: 'set' } },
// Each column names its own reduction, and the title says which one, so
// the footer reads as what it is.
{ field: 'price', title: 'Price / median', type: 'number', format: { decimals: 4 }, total: 'median' },
{ field: 'bid', title: 'Bid / p95', type: 'number', format: { decimals: 4 }, total: 'p95' },
{ field: 'change', title: 'Change / stddev', type: 'number', format: { style: 'percent', decimals: 2 }, total: 'stddev' },
{ field: 'volume', title: 'Volume / IQR', type: 'number', format: { notation: 'compact' }, total: 'iqr' },
{ field: 'notional', title: 'Notional / sum', type: 'number',
format: { style: 'currency', currency: 'USD', decimals: 2 }, total: 'sum' },
];
const rows = [/* trading book records */];
@Component({
selector: 'app-root',
standalone: true,
imports: [LatticeGridComponent],
template: '<lattice-grid [config]="grid" style="display:block;height:460px"></lattice-grid>',
})
export class AppComponent {
grid = {
rowKey: 'id',
columnDefaults: { filter: true },
columns: columns,
rows: rows,
};
}
bootstrapApplication(AppComponent, {
providers: [provideLattice({ createGrid })],
});