DocsChartsSpatial & maps
PolygonMap
React example follows below.
ts
import { PolygonMap } 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]]], },]; <PolygonMap features={ukFeatures} />ts
<script setup lang="ts">import { PolygonMap } 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]]], },];</script> <template> <PolygonMap :features='ukFeatures' /></template>ts
import { ChangeDetectionStrategy, Component } from "@angular/core";import { GrassrootPolygonMap } from "@grassroot/charts-angular"; @Component({ selector: "app-polygon-map-chart-demo", standalone: true, imports: [GrassrootPolygonMap], changeDetection: ChangeDetectionStrategy.OnPush, template: `<grassroot-polygon-map [features]='ukFeatures' />`,})export class PolygonMapDemoComponent { 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]]], }, ];} export default PolygonMapDemoComponent;ts
<script lang="ts"> import { PolygonMap } 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]]], }, ];</script> <PolygonMap features={ukFeatures} />ts
/** @jsxImportSource solid-js */import { PolygonMap } 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]]], },]; export default function PolygonMapDemo() { return <PolygonMap features={ukFeatures} />;}Installation
bash
pnpm dlx grassroot add chart/polygon-mapbash
npx grassroot@latest add chart/polygon-mapbash
yarn dlx grassroot add chart/polygon-mapbash
bunx grassroot add chart/polygon-mapAPI Reference
| Prop | Type | Default |
|---|---|---|
features | readonly GeoFeature[] | undefined | — |
points | readonly GeoPoint[] | undefined | — |
gpuBackend | ChartGpuBackend | undefined | — |
width | number | undefined | — |
height | number | undefined | — |
renderPlanMode | "svg" | "host" | undefined | — |
rendererStrategy | Partial<import("@grassroot/core").ChartRendererStrategy> | undefined | — |
showGrid | boolean | undefined | — |
legend | boolean | import("@grassroot/interaction/core").LegendConfig | undefined | — |
tooltip | boolean | import("./base").ExpandedChartTooltipConfig<unknown> | undefined | — |
animation | boolean | import("./base").ExpandedChartAnimationConfig | undefined | — |
interactiveGates every pointer/keyboard interaction the shell owns (hit-test on pointer move, focus-to-first, arrow navigation, Escape) and, with `keyboardNavigation`, whether the plot surface is focusable at all. | boolean | undefined | — |
hiddenSeries | readonly string[] | undefined | — |
defaultHiddenSeries | readonly string[] | undefined | — |
onHiddenSeriesChange | ((ids: readonly string[]) => void) | undefined | — |
activeDatum | string | null | undefined | — |
defaultActiveDatumUncontrolled initial value for the `activeDatum`/`onActiveDatumChange` pair. | string | null | undefined | — |
onActiveDatumChange | ((id: string | null) => void) | undefined | — |
renderer | ChartRenderer | undefined | — |
className | string | undefined | — |
theme | import("@grassroot/theme").PartialChartTheme | undefined | — |
title | string | undefined | — |
description | string | undefined | — |
ariaLabel | string | undefined | — |
keyboardNavigation | boolean | undefined | — |