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

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-map
bash
npx grassroot@latest add chart/polygon-map
bash
yarn dlx grassroot add chart/polygon-map
bash
bunx grassroot add chart/polygon-map

API Reference

PolygonMapProps
PropTypeDefault
featuresreadonly GeoFeature[] | undefined
pointsreadonly GeoPoint[] | undefined
gpuBackendChartGpuBackend | undefined
widthnumber | undefined
heightnumber | undefined
renderPlanMode"svg" | "host" | undefined
rendererStrategyPartial<import("@grassroot/core").ChartRendererStrategy> | undefined
showGridboolean | undefined
legendboolean | import("@grassroot/interaction/core").LegendConfig | undefined
tooltipboolean | import("./base").ExpandedChartTooltipConfig<unknown> | undefined
animationboolean | 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
hiddenSeriesreadonly string[] | undefined
defaultHiddenSeriesreadonly string[] | undefined
onHiddenSeriesChange((ids: readonly string[]) => void) | undefined
activeDatumstring | null | undefined
defaultActiveDatumUncontrolled initial value for the `activeDatum`/`onActiveDatumChange` pair.string | null | undefined
onActiveDatumChange((id: string | null) => void) | undefined
rendererChartRenderer | undefined
classNamestring | undefined
themeimport("@grassroot/theme").PartialChartTheme | undefined
titlestring | undefined
descriptionstring | undefined
ariaLabelstring | undefined
keyboardNavigationboolean | undefined