Lattice Grid Buy a licence

demo D258

Hex map in ESM

Snap places to a tidy hex grid so a small region reads as clearly as a large one

type: 'hexmap', lon, lat

This snaps places onto a tidy hex grid so a small region reads as clearly as a large one. It gives every area equal visual weight, so a pattern is not dominated by the physical size of the places on the map.

Building…
Loading a live grid…

This is the ES module version. The grid is imported straight from a CDN as a module, the same configuration as the vanilla tab without a global script tag, so it drops into any bundler or a bare module script.

The configuration

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.71.0/lattice-grid.min.css">

<div id="grid" style="height: 320px"></div>
<div id="chart" style="height: 340px"></div>

<script type="module">
  import { createChart } from '@toclocoinc/lattice-grid/modules/charts';
  import '@toclocoinc/lattice-grid/modules/chart-hexmap';  // opt in to the hexmap type

  const grid = createGrid(document.getElementById('grid'), {
    rowKey: 'id',
    columns: [
      { field: 'city', title: 'City' },
      { field: 'lon', title: 'Longitude', type: 'number', format: { decimals: 2 } },
      { field: 'lat', title: 'Latitude', type: 'number', format: { decimals: 2 } },
      { field: 'users', title: 'Users (m)', type: 'number', format: { decimals: 1 }, total: 'sum' },
    ],
    rows,  // one city a row: city, lon, lat, users
  });

  // lon and lat are snapped to a hex grid, so a small place reads as loud as a
  // large one.
  createChart({
    grid,
    container: document.getElementById('chart'),
    type: 'hexmap',
    lon: 'lon',
    lat: 'lat',
    title: 'Cities on a hex grid',
  });
</script>