Lattice Grid Buy a licence

demo D180

Profiling a column: JavaScript Data Grid Demo

Count, spread, quartiles and outliers from the API, into a panel of your own

grid.statistics.profile(col)

This grid reads a column's count, spread, quartiles and outliers from the statistics API into a panel of your own. It lets you build a bespoke profiling view on the figures the grid already computes, rather than calculating them yourself.

Building…
Loading a live grid…

The configuration

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

<div id="grid" style="height: 420px"></div>
<div id="panel" style="margin-top: 12px; font: 13px system-ui; display: flex; flex-wrap: wrap; gap: .4rem 1.4rem"></div>

<script>
  const grid = LatticeGrid.createGrid(document.getElementById('grid'), {
    rowKey: 'id',
    columnDefaults: { filter: true },
    toolPanel: { side: 'left', panels: ['filters', 'columns'] },
    columns: [
      { field: 'symbol', title: 'Symbol', layout: { pin: 'start', width: 120 } },
      { field: 'desk', title: 'Desk', filter: { type: 'set' } },
      { field: 'region', title: 'Region', filter: { type: 'set' } },
      { field: 'price', title: 'Price', type: 'number', format: { decimals: 4 } },
      { field: 'bid', title: 'Bid', type: 'number', format: { decimals: 4 } },
      { field: 'volume', title: 'Volume', type: 'number', format: { notation: 'compact' } },
      { field: 'notional', title: 'Notional', type: 'number',
        format: { style: 'currency', currency: 'USD', decimals: 2 }, total: 'sum' },
    ],
    rows,  // trading book: symbol, desk, region, price, bid, volume, notional
  });

  const panel = document.getElementById('panel');
  const render = () => {
    // One column, summarised: count, spread, quartiles and the outliers.
    const p = grid.statistics.profile('notional');
    const fig = (label, v) => '<span><strong>' + label + '</strong> ' +
      (typeof v === 'number' ? Math.round(v).toLocaleString('en-GB') : v) + '</span>';
    panel.innerHTML =
      fig('rows', p.rows) + fig('min', p.min) + fig('median', p.median) +
      fig('mean', p.mean) + fig('max', p.max) + fig('IQR', p.iqr) +
      fig('sigma', p.stddev) + fig('outliers', p.outliers.length);
  };
  // Recompute whenever the grid is filtered, so the figures track the view.
  grid.on('filter:changed', render);
  render();
</script>