Lattice Grid Buy a licence

demo D193

Statistics without a panel

Every figure available to your own interface, as an object

grid.statistics.*

Building…
Loading a live grid…

The configuration

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.28.0/lattice-grid.min.css">

<div id="grid" style="height: 460px"></div>
<pre id="out" style="margin-top: 12px"></pre>

<script type="module">
  import { createGrid } from 'https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.28.0/modules/htmx.esm.js';

  const grid = createGrid(document.getElementById('grid'), {
    rowKey: 'id',
    toolPanel: { side: 'left', panels: ['filters', 'columns'] },
    columns: [
      { field: 'symbol', title: 'Symbol', layout: { pin: 'start', width: 120 } },
      { field: 'desk', title: 'Desk', filter: { type: 'set' } },
      { field: 'price', title: 'Price', type: 'number' },
      { field: 'bid', title: 'Bid', type: 'number' },
      { field: 'volume', title: 'Volume', type: 'number' },
      { field: 'notional', title: 'Notional', type: 'number',
        format: { style: 'currency', currency: 'USD' }, total: 'sum' },
    ],
    rows,  // e.g. [{ id: 1, symbol: 'ABC', desk: 'Rates', price: 101.2, bid: 101.1, volume: 4200, notional: 425040 }, …]
  });

  // The statistics API reads straight from the grid over the rows that survive
  // the filters, so every figure moves as the table is filtered.
  const out = document.getElementById('out');
  const report = () => {
    out.textContent = JSON.stringify({
      profile:     grid.statistics.profile('notional'),
      correlation: grid.statistics.correlation('price', 'bid'),
      regression:  grid.statistics.regression('price', 'bid'),
      spearman:    grid.statistics.spearman('price', 'bid'),
    }, null, 2);
  };
  grid.on('filter:changed', report);  // every figure follows the filters
  report();
</script>