Lattice Grid Buy a licence

demo D183

Statistical values in a column

A column's median, deviation and percentile, read into computed columns

value.compute

Building…
Loading a live grid…

The configuration

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.27.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.27.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: 'price', title: 'Price', type: 'number' },
    ],
    rows,  // e.g. [{ id: 1, symbol: 'ABC', price: 101.2 }, …]
  });

  // Named reductions read 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 = 'median ' + grid.statistics.reduce('price', 'median')
      + ' · stddev ' + grid.statistics.reduce('price', 'stddev')
      + ' · p90 ' + grid.statistics.reduce('price', 'p90');
  };
  grid.on('filter:changed', report);
  report();
</script>