Lattice Grid Buy a licence

demo D194

Variation along an ordering

Volatility, growth and drawdown, from rows loaded out of order

grid.statistics.series(col, { by })

Building…
Loading a live grid…

The configuration

import * as ng from '@angular/core';
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 createLatticeGrid from '@toclocoinc/lattice-grid/modules/angular';

const { LatticeGridComponent } = createLatticeGrid({ ng, createGrid });

const columns = [
  { field: 'date', title: 'Date', type: 'date', layout: { pin: 'start', width: 150 } },
  { field: 'price', title: 'Price', type: 'number' },
];

@Component({
  selector: 'app-root',
  standalone: true,
  imports: [LatticeGridComponent],
  template:
    '<lattice-grid [config]="grid" (filter-changed)="report()" style="display:block;height:460px"></lattice-grid>' +
    '<pre style="margin-top:12px">{{ out }}</pre>',
})
export class AppComponent implements AfterViewInit {
  @ViewChild(LatticeGridComponent) gridRef!: LatticeGridComponent;
  out = '';

  grid = {
    rowKey: 'id',
    toolPanel: { side: 'left', panels: ['filters', 'columns'] },
    columns,
    rows: [/* a dated price series */],
  };

  // by is required: the series reads rows as loaded, not in the grid's sort.
  // Every figure is over the filtered rows, so narrowing the range moves them.
  report() {
    const grid = this.gridRef && this.gridRef.grid;
    if (!grid) return;
    this.out = JSON.stringify(grid.statistics.series('price', { by: 'date', periodsPerYear: 252 }), null, 2);
  }

  ngAfterViewInit() { this.report(); }
}

bootstrapApplication(AppComponent);