Lattice Grid Buy a licence

demo D173

Brushing a time range in Web Component

Drag a range on the chart and the grid narrows to it

brush: true

This lets you drag a range across a time chart and narrows the grid to it. It gives a reader a quick way to focus on a period, selecting the window on the chart and reading the matching rows in the grid.

Building…
Loading a live grid…

This is the web component version. A lattice-grid custom element renders the grid with no build step, its configuration set as a property, so it works on a page that has no bundler at all.

The configuration

<link rel="stylesheet" href="https://cdn.latticegrid.dev/lattice-grid@1.107.0/lattice-grid.min.css">

<script type="module">
  import { defineLatticeGrid } from 'https://cdn.latticegrid.dev/lattice-grid@1.107.0/modules/webcomponent.esm.min.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.latticegrid.dev/lattice-grid@1.107.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>