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

<script>
  import { createGrid } from 'https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.28.0/lattice-grid.esm.min.js';
  import createLatticeAction from 'https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.28.0/modules/svelte.esm.min.js';

  const lattice = createLatticeAction({ createGrid });

  let out = '';

  const config = {
    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,
    // onGrid hands over the live grid the moment it is created. Profile,
    // correlation, regression and rank correlation are read straight from the
    // grid, and every figure follows the filters: narrow the rows and they move.
    onGrid: (grid) => {
      const report = () => {
        out = 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);
      report();
    },
  };
</script>

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

<div use:lattice={config} style="height: 460px"></div>
<pre style="margin-top: 12px">{out}</pre>