demo D258
Hex map: JavaScript Data Grid Demo
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.
Loading a live grid…
The configuration
<link rel="stylesheet" href="https://cdn.latticegrid.dev/lattice-grid@1.108.1/lattice-grid.min.css">
<script src="https://cdn.latticegrid.dev/lattice-grid@1.108.1/lattice-grid.min.js"></script>
<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 = LatticeGrid.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>