demo D186
Shadow columns: rate and streak in Svelte
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.
This is the Svelte version. A use action attaches the grid to a plain element, so no framework runtime is passed in and the component stays small, while the configuration is ordinary Svelte state.
The configuration
<script>
import { createGrid } from 'https://cdn.latticegrid.dev/lattice-grid@1.108.0/lattice-grid.esm.min.js';
import createLatticeAction from 'https://cdn.latticegrid.dev/lattice-grid@1.108.0/modules/svelte.esm.min.js';
const lattice = createLatticeAction({ createGrid });
const config = {
rowKey: 'id',
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' },
{ id: 'rate', title: 'Per second', shadow: { of: 'price', kind: 'rate' }, type: 'number', format: { signed: true } },
{ id: 'streak', title: 'Run', shadow: { of: 'price', kind: 'streak' }, type: 'number', format: { signed: true } },
{ id: 'since', title: 'Since move', shadow: { of: 'price', kind: 'sinceUpdate' }, type: 'duration' },
{ id: 'hist', title: 'Recent', shadow: { of: 'price', kind: 'history' }, cell: { render: 'line' } },
],
rows,
};
</script>
<svelte:head>
<link rel="stylesheet" href="https://cdn.latticegrid.dev/lattice-grid@1.108.0/lattice-grid.min.css">
</svelte:head>
<div use:lattice={config} style="height: 460px"></div>