demo D180
Profiling a column
Count, spread, quartiles and outliers from the API, into a panel of your own
grid.statistics.profile(col)
Loading a live grid…
The configuration
<script>
import { createGrid } from 'https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.27.0/lattice-grid.esm.min.js';
import createLatticeAction from 'https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.27.0/modules/svelte.esm.min.js';
const lattice = createLatticeAction({ createGrid });
let profile = '';
const config = {
rowKey: 'id',
toolPanel: { side: 'left', panels: ['filters', 'columns'], exportName: 'book' },
columnDefaults: { filter: true },
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: 'notional', title: 'Notional', type: 'number',
format: { style: 'currency', currency: 'GBP' }, total: 'sum' },
],
rows, // trading book records
// onGrid hands over the live grid the moment it is created. profile() returns
// the count, the range, the quartiles, the spread and the outliers of one
// column over the filtered rows. Recompute it whenever the filters change.
onGrid: (grid) => {
const report = () => {
profile = JSON.stringify(grid.statistics.profile('notional'), null, 2);
};
grid.on('filter:changed', report);
report();
},
};
</script>
<svelte:head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.27.0/lattice-grid.min.css">
</svelte:head>
<div use:lattice={config} style="height: 460px"></div>
<pre style="margin-top: 12px">{profile}</pre>