Lattice Grid Buy a licence

demo D206

A fitted line in Angular

Least squares per series, with R², agreeing with the API

fit: true

This draws a least-squares line through each series in a scatter, with R squared shown and matching the API. It puts a trend and its goodness of fit on the picture, so the strength of a relationship reads directly off the chart.

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 } 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 { LatticeGridComponent, provideLattice } from '@toclocoinc/lattice-grid/angular';

const columns = [
  { field: 'symbol', title: 'Symbol', layout: { pin: 'start', width: 120 } },
  { field: 'desk', title: 'Desk', filter: { type: 'set' } },
  { field: 'price', title: 'Price', 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' },
];

const rows = [/* trading records, one per instrument */];



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

  grid = {
    rowKey: 'id',
    columns: columns,
    rows: rows,
  };

  // The grid is created once the view has rendered, so the live instance
  // arrives on grid-ready rather than in ngAfterViewInit.
  onGridReady() {
    const grid = this.gridRef.grid;
    // fit draws a least-squares line through the points, per series, with its
    // R2 beside it. The chart reads the live grid through the ref, so the fit
    // recomputes over whatever the filters leave.
    createChart({ grid, container: '#chart', type: 'scatter', x: 'volume', y: 'notional',
      fit: true, title: 'Notional against volume, fitted' });
  }
}

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