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">
<script type="module">
import { defineLatticeGrid } from 'https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.27.0/modules/webcomponent.esm.js';
defineLatticeGrid();
</script>
<div id="chart" style="height: 300px"></div>
<lattice-grid row-key="id" style="display: block; height: 320px; margin-top: 14px"></lattice-grid>
<script type="module">
import { createChart } from 'https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.27.0/modules/charts.esm.min.js';
const el = document.querySelector('lattice-grid');
el.config = {
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' } },
],
};
el.rows = rows; // one row a day, in date order
// brush lets you drag a range across the chart to narrow the grid to those
// days. The chart reads el.grid, the live grid inside the element, so one
// gesture moves both views.
createChart({ grid: el.grid, container: '#chart', type: 'line', x: 'date', y: 'price', brush: true });
</script>