demo D173
Brushing a time range
Drag a range on the chart and the grid narrows to it
brush: true
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">
<div id="chart" style="height: 300px"></div>
<div id="grid" style="height: 340px; margin-top: 14px"></div>
<script type="module">
import { createGrid } from 'https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.27.0/modules/htmx.esm.js';
import { createChart } from 'https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.27.0/modules/charts.esm.min.js';
const grid = createGrid(document.getElementById('grid'), {
rowKey: 'id',
columns: [
{ field: 'date', title: 'Date', type: 'dateString', layout: { pin: 'start', width: 150 } },
{ field: 'price', title: 'Price', type: 'number', format: { decimals: 2 } },
{ field: 'volume', title: 'Volume', type: 'number', format: { notation: 'compact' } },
],
rows, // one row per day
});
// brush lets a reader drag a range across the chart to narrow the grid to
// those days, so one gesture moves the chart and the table together.
createChart({ grid, container: '#chart', type: 'line', x: 'date', y: 'price', brush: true });
</script>