demo D187
Marking a baseline in Vue
"Mark all" resets every delta to now
grid.statistics.rebase(col)
This grid resets every delta to now with a single 'mark all', setting a fresh baseline. It lets a reader say 'watch from here', so change tracking restarts from the current moment rather than page load.
This is the Vue 3 version. A createLatticeGrid component takes the configuration through v-bind, and reactive data flows straight into the grid, so it updates the way the rest of your Vue app does.
The configuration
<link rel="stylesheet" href="https://cdn.latticegrid.dev/lattice-grid@1.108.0/lattice-grid.min.css">
<style>
#grid { margin-top: 8px; }
#grid > div { height: 440px; }
</style>
<div id="app"></div>
<script type="module">
import * as Vue from 'https://esm.sh/vue@3/dist/vue.esm-browser.prod.js';
import { createGrid } from 'https://cdn.latticegrid.dev/lattice-grid@1.108.0/lattice-grid.esm.min.js';
import createLatticeGrid from 'https://cdn.latticegrid.dev/lattice-grid@1.108.0/modules/vue.esm.min.js';
const LatticeGrid = createLatticeGrid({ vue: Vue, createGrid });
Vue.createApp({
components: { LatticeGrid },
data() {
return {
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, // one symbol per row
},
};
},
methods: {
// rebase moves every baseline to the current value, so the deltas start again.
markAll() {
this.$refs.grid.grid().statistics.rebase('price');
},
},
template: `
<div>
<button @click="markAll">Mark all</button>
<div id="grid"><lattice-grid ref="grid" v-bind="config" /></div>
</div>
`,
}).mount('#app');
</script>