Lattice Grid Buy a licence

demo D186

Shadow columns: rate and streak: JavaScript Data Grid Demo

Speed of change, direction runs, and a sparkline of recent history

shadow: { of, kind: 'rate' }

This grid adds shadow columns for speed of change, runs in one direction, and a sparkline of recent history. It shows not just where a value is but how fast and which way it is moving, per row.

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: 460px"></div>

<script>
  const grid = LatticeGrid.createGrid(document.getElementById('grid'), {
    rowKey: 'id',
    // Flash a cell for half a second when its value moves.
    highlightOnChange: { duration: 500 },
    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 } },
      { id: 'rate', title: 'Per second', shadow: { of: 'price', kind: 'rate' }, type: 'number', format: { decimals: 4, signed: true }, layout: { width: 130 } },
      { id: 'streak', title: 'Run', shadow: { of: 'price', kind: 'streak' }, type: 'number', format: { signed: true }, layout: { width: 90 } },
      { id: 'since', title: 'Since last move', shadow: { of: 'price', kind: 'sinceUpdate' }, type: 'duration', layout: { width: 150 } },
      // The recent values, drawn as an inline sparkline.
      { id: 'history', title: 'Recent', shadow: { of: 'price', kind: 'history' }, cell: { render: 'line' }, layout: { width: 140 } },
    ],
    rows,  // trading book: symbol, desk, region, price
  });

  setInterval(() => {
    const updates = rows.slice(0, 40).map((r) => ({
      id: r.id,
      price: Math.round(r.price * (1 + (Math.random() - 0.5) * 0.02) * 1e4) / 1e4,
    }));
    grid.rows.apply({ update: updates });
  }, 120);
</script>