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
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.27.0/lattice-grid.min.css">
<style>
#grid > div { height: 460px; }
#out { margin-top: 12px; }
</style>
<div id="app"></div>
<script type="module">
import * as Vue from 'https://esm.sh/vue@3';
import { createGrid } from 'https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.27.0/lattice-grid.esm.min.js';
import createLatticeGrid from 'https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.27.0/modules/vue.esm.min.js';
const LatticeGrid = createLatticeGrid({ vue: Vue, createGrid });
Vue.createApp({
components: { LatticeGrid },
data() {
return {
config: {
rowKey: 'id',
toolPanel: { side: 'left', panels: ['filters', 'columns'] },
columns: [
{ field: 'symbol', title: 'Symbol', layout: { pin: 'start', width: 120 } },
{ field: 'desk', title: 'Desk', filter: { type: 'set' } },
{ field: 'price', title: 'Price', type: 'number' },
{ field: 'bid', title: 'Bid', type: 'number' },
{ field: 'volume', title: 'Volume', type: 'number' },
{ field: 'notional', title: 'Notional', type: 'number',
format: { style: 'currency', currency: 'USD' }, total: 'sum' },
],
rows, // trade records, one per row
},
};
},
mounted() {
// Recompute once the grid is live, then on every filter change.
this.report();
},
methods: {
// profile summarises one column over the filtered rows into a single object
// you can read straight into a panel of your own.
report() {
const grid = this.$refs.grid.grid();
document.getElementById('out').textContent =
JSON.stringify(grid.statistics.profile('notional'), null, 2);
},
},
template: `
<div id="grid"><lattice-grid ref="grid" v-bind="config" @filter-changed="report" /></div>
<pre id="out"></pre>
`,
}).mount('#app');
</script>