demo D193
Statistics without a panel: JavaScript Data Grid Demo
Every figure available to your own interface, as an object
grid.statistics.*
This grid exposes every figure it computes as a plain object, for your own interface with no panel involved. It lets you take the statistics into a custom dashboard or export, so the numbers are available wherever you need them.
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>
<pre id="report" style="margin-top: 12px; font: 12px ui-monospace, monospace; background: #fafbfc; border: 1px solid #e6e6e6; border-radius: 8px; padding: 10px; max-height: 260px; overflow: auto"></pre>
<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 report = document.getElementById('report');
const render = () => {
const s = grid.statistics;
// The same figures a panel shows, as an object you can render anywhere.
report.textContent = JSON.stringify({
profile: s.profile('notional'),
correlation: s.correlation('price', 'bid'),
regression: s.regression('price', 'bid'),
spearman: s.spearman('price', 'bid'),
weightedMedian: s.weightedQuantile('price', 'volume', 0.5),
}, null, 2);
};
grid.on('filter:changed', render);
render();
</script>