Lattice Grid Buy a licence

demo D183

Statistical values in a column in Web Component

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

value.compute

This grid reads a column's median, deviation and percentile into computed columns. It lets a per-row calculation reference a whole-column statistic, so a value can be compared against its column's own figures inline.

Building…
Loading a live grid…

This is the web component version. A lattice-grid custom element renders the grid with no build step, its configuration set as a property, so it works on a page that has no bundler at all.

The configuration

<link rel="stylesheet" href="https://cdn.latticegrid.dev/lattice-grid@1.107.0/lattice-grid.min.css">

<script type="module">
  import { defineLatticeGrid } from 'https://cdn.latticegrid.dev/lattice-grid@1.107.0/modules/webcomponent.esm.min.js';
  defineLatticeGrid();
</script>

<lattice-grid row-key="id" style="display: block; height: 460px"></lattice-grid>
<pre id="out" style="margin-top: 12px"></pre>

<script type="module">
  const el = document.querySelector('lattice-grid');
  el.config = {
    toolPanel: { side: 'left', panels: ['filters', 'columns'] },
    columns: [
      { field: 'symbol', title: 'Symbol', layout: { pin: 'start', width: 120 } },
      { field: 'price', title: 'Price', type: 'number' },
    ],
  };
  el.rows = rows;  // trading book records

  // reduce() runs a named figure over the filtered rows. el.grid is the live
  // grid inside the element, so every figure follows the filters. Recompute
  // whenever they change.
  const grid = el.grid;
  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>