demo D187
Marking a baseline
"Mark all" resets every delta to now
grid.statistics.rebase(col)
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 grid;
const config = {
rowKey: 'id',
columns: [
{ field: 'symbol', title: 'Symbol', layout: { pin: 'start', width: 120 } },
{ field: 'price', title: 'Price', type: 'number' },
{ id: 'delta', title: 'Change', shadow: { of: 'price', kind: 'delta' }, type: 'number', format: { signed: true } },
{ id: 'first', title: 'Baseline', shadow: { of: 'price', kind: 'firstValue' }, type: 'number' },
],
rows,
// onGrid hands over the live grid the moment it is created, so the button
// below can rebase it.
onGrid: (g) => { grid = g; },
};
// rebase moves every baseline to the current value, so the deltas start again.
const markAll = () => grid.statistics.rebase('price');
</script>
<svelte:head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.28.0/lattice-grid.min.css">
</svelte:head>
<button on:click={markAll}>Mark all</button>
<div use:lattice={config} style="height: 440px; margin-top: 8px"></div>