CLI previewInstall commands shown on this site are not released yet.

DocsChartsSpatial & maps

HexbinMap

React example follows below.
ts
import { HexbinMap } from "@grassroot/charts-react";
const ukFeatures = [
{
id: "scotland",
label: "Scotland",
value: 68,
color: "var(--accent)",
polygons: [[[-6.8, 55.0], [-5.5, 55.2], [-4.2, 56.0], [-2.4, 56.0], [-1.8, 57.0], [-3.1, 58.6], [-4.8, 58.7], [-6.2, 57.8], [-7.4, 57.2], [-6.8, 55.0]]],
},
{
id: "england-wales",
label: "England/Wales",
value: 84,
color: "var(--vs-success)",
polygons: [[[-5.7, 50.1], [-3.8, 50.2], [-1.2, 50.7], [1.4, 51.2], [1.1, 52.5], [-0.2, 53.2], [-1.8, 53.8], [-3.2, 53.5], [-4.5, 52.8], [-5.3, 51.7], [-5.7, 50.1]]],
},
{
id: "northern-ireland",
label: "N. Ireland",
value: 46,
color: "var(--vs-warning)",
polygons: [[[-8.2, 54.0], [-6.2, 54.1], [-5.6, 55.0], [-6.5, 55.5], [-7.9, 55.1], [-8.2, 54.0]]],
},
];
const geoPoints = [
{ longitude: -0.1, latitude: 51.5, value: 10, label: "London" },
{ longitude: -3.2, latitude: 55.9, value: 7, label: "Edinburgh" },
{ longitude: -3.2, latitude: 51.5, value: 5, label: "Cardiff" },
{ longitude: -5.9, latitude: 54.6, value: 4, label: "Belfast" },
];
<HexbinMap features={ukFeatures} points={geoPoints} />
ts
<script setup lang="ts">
import { HexbinMap } from "@grassroot/charts-vue";
const ukFeatures = [
{
id: "scotland",
label: "Scotland",
value: 68,
color: "var(--accent)",
polygons: [[[-6.8, 55.0], [-5.5, 55.2], [-4.2, 56.0], [-2.4, 56.0], [-1.8, 57.0], [-3.1, 58.6], [-4.8, 58.7], [-6.2, 57.8], [-7.4, 57.2], [-6.8, 55.0]]],
},
{
id: "england-wales",
label: "England/Wales",
value: 84,
color: "var(--vs-success)",
polygons: [[[-5.7, 50.1], [-3.8, 50.2], [-1.2, 50.7], [1.4, 51.2], [1.1, 52.5], [-0.2, 53.2], [-1.8, 53.8], [-3.2, 53.5], [-4.5, 52.8], [-5.3, 51.7], [-5.7, 50.1]]],
},
{
id: "northern-ireland",
label: "N. Ireland",
value: 46,
color: "var(--vs-warning)",
polygons: [[[-8.2, 54.0], [-6.2, 54.1], [-5.6, 55.0], [-6.5, 55.5], [-7.9, 55.1], [-8.2, 54.0]]],
},
];
const geoPoints = [
{ longitude: -0.1, latitude: 51.5, value: 10, label: "London" },
{ longitude: -3.2, latitude: 55.9, value: 7, label: "Edinburgh" },
{ longitude: -3.2, latitude: 51.5, value: 5, label: "Cardiff" },
{ longitude: -5.9, latitude: 54.6, value: 4, label: "Belfast" },
];
</script>
<template>
<HexbinMap :features='ukFeatures' :points='geoPoints' />
</template>
ts
import { ChangeDetectionStrategy, Component } from "@angular/core";
import { GrassrootHexbinMap } from "@grassroot/charts-angular";
@Component({
selector: "app-hexbin-map-chart-demo",
standalone: true,
imports: [GrassrootHexbinMap],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `<grassroot-hexbin-map [features]='ukFeatures' [points]='geoPoints' />`,
})
export class HexbinMapDemoComponent {
readonly ukFeatures = [
{
id: "scotland",
label: "Scotland",
value: 68,
color: "var(--accent)",
polygons: [[[-6.8, 55.0], [-5.5, 55.2], [-4.2, 56.0], [-2.4, 56.0], [-1.8, 57.0], [-3.1, 58.6], [-4.8, 58.7], [-6.2, 57.8], [-7.4, 57.2], [-6.8, 55.0]]],
},
{
id: "england-wales",
label: "England/Wales",
value: 84,
color: "var(--vs-success)",
polygons: [[[-5.7, 50.1], [-3.8, 50.2], [-1.2, 50.7], [1.4, 51.2], [1.1, 52.5], [-0.2, 53.2], [-1.8, 53.8], [-3.2, 53.5], [-4.5, 52.8], [-5.3, 51.7], [-5.7, 50.1]]],
},
{
id: "northern-ireland",
label: "N. Ireland",
value: 46,
color: "var(--vs-warning)",
polygons: [[[-8.2, 54.0], [-6.2, 54.1], [-5.6, 55.0], [-6.5, 55.5], [-7.9, 55.1], [-8.2, 54.0]]],
},
];
readonly geoPoints = [
{ longitude: -0.1, latitude: 51.5, value: 10, label: "London" },
{ longitude: -3.2, latitude: 55.9, value: 7, label: "Edinburgh" },
{ longitude: -3.2, latitude: 51.5, value: 5, label: "Cardiff" },
{ longitude: -5.9, latitude: 54.6, value: 4, label: "Belfast" },
];
}
export default HexbinMapDemoComponent;
ts
<script lang="ts">
import { HexbinMap } from "@grassroot/charts-svelte";
const ukFeatures = [
{
id: "scotland",
label: "Scotland",
value: 68,
color: "var(--accent)",
polygons: [[[-6.8, 55.0], [-5.5, 55.2], [-4.2, 56.0], [-2.4, 56.0], [-1.8, 57.0], [-3.1, 58.6], [-4.8, 58.7], [-6.2, 57.8], [-7.4, 57.2], [-6.8, 55.0]]],
},
{
id: "england-wales",
label: "England/Wales",
value: 84,
color: "var(--vs-success)",
polygons: [[[-5.7, 50.1], [-3.8, 50.2], [-1.2, 50.7], [1.4, 51.2], [1.1, 52.5], [-0.2, 53.2], [-1.8, 53.8], [-3.2, 53.5], [-4.5, 52.8], [-5.3, 51.7], [-5.7, 50.1]]],
},
{
id: "northern-ireland",
label: "N. Ireland",
value: 46,
color: "var(--vs-warning)",
polygons: [[[-8.2, 54.0], [-6.2, 54.1], [-5.6, 55.0], [-6.5, 55.5], [-7.9, 55.1], [-8.2, 54.0]]],
},
];
const geoPoints = [
{ longitude: -0.1, latitude: 51.5, value: 10, label: "London" },
{ longitude: -3.2, latitude: 55.9, value: 7, label: "Edinburgh" },
{ longitude: -3.2, latitude: 51.5, value: 5, label: "Cardiff" },
{ longitude: -5.9, latitude: 54.6, value: 4, label: "Belfast" },
];
</script>
<HexbinMap features={ukFeatures} points={geoPoints} />
ts
/** @jsxImportSource solid-js */
import { HexbinMap } from "@grassroot/charts-solid";
const ukFeatures = [
{
id: "scotland",
label: "Scotland",
value: 68,
color: "var(--accent)",
polygons: [[[-6.8, 55.0], [-5.5, 55.2], [-4.2, 56.0], [-2.4, 56.0], [-1.8, 57.0], [-3.1, 58.6], [-4.8, 58.7], [-6.2, 57.8], [-7.4, 57.2], [-6.8, 55.0]]],
},
{
id: "england-wales",
label: "England/Wales",
value: 84,
color: "var(--vs-success)",
polygons: [[[-5.7, 50.1], [-3.8, 50.2], [-1.2, 50.7], [1.4, 51.2], [1.1, 52.5], [-0.2, 53.2], [-1.8, 53.8], [-3.2, 53.5], [-4.5, 52.8], [-5.3, 51.7], [-5.7, 50.1]]],
},
{
id: "northern-ireland",
label: "N. Ireland",
value: 46,
color: "var(--vs-warning)",
polygons: [[[-8.2, 54.0], [-6.2, 54.1], [-5.6, 55.0], [-6.5, 55.5], [-7.9, 55.1], [-8.2, 54.0]]],
},
];
const geoPoints = [
{ longitude: -0.1, latitude: 51.5, value: 10, label: "London" },
{ longitude: -3.2, latitude: 55.9, value: 7, label: "Edinburgh" },
{ longitude: -3.2, latitude: 51.5, value: 5, label: "Cardiff" },
{ longitude: -5.9, latitude: 54.6, value: 4, label: "Belfast" },
];
export default function HexbinMapDemo() {
return <HexbinMap features={ukFeatures} points={geoPoints} />;
}

Installation

bash
pnpm dlx grassroot add chart/hexbin-map
bash
npx grassroot@latest add chart/hexbin-map
bash
yarn dlx grassroot add chart/hexbin-map
bash
bunx grassroot add chart/hexbin-map

API Reference

HexbinMapProps
PropTypeDefault
pointsrequiredreadonly GeoPoint[]
featuresreadonly GeoFeature[] | undefined
radiusnumber | undefined