DocsChartsSpatial & maps
CustomProjectionMap
React example follows below.
ts
import { CustomProjectionMap } 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" },]; <CustomProjectionMap features={ukFeatures} points={geoPoints} />ts
<script setup lang="ts">import { CustomProjectionMap } 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> <CustomProjectionMap :features='ukFeatures' :points='geoPoints' /></template>ts
import { ChangeDetectionStrategy, Component } from "@angular/core";import { GrassrootCustomProjectionMap } from "@grassroot/charts-angular"; @Component({ selector: "app-custom-projection-map-chart-demo", standalone: true, imports: [GrassrootCustomProjectionMap], changeDetection: ChangeDetectionStrategy.OnPush, template: `<grassroot-custom-projection-map [features]='ukFeatures' [points]='geoPoints' />`,})export class CustomProjectionMapDemoComponent { 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 CustomProjectionMapDemoComponent;ts
<script lang="ts"> import { CustomProjectionMap } 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> <CustomProjectionMap features={ukFeatures} points={geoPoints} />ts
/** @jsxImportSource solid-js */import { CustomProjectionMap } 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 CustomProjectionMapDemo() { return <CustomProjectionMap features={ukFeatures} points={geoPoints} />;}Installation
bash
pnpm dlx grassroot add chart/custom-projection-mapbash
npx grassroot@latest add chart/custom-projection-mapbash
yarn dlx grassroot add chart/custom-projection-mapbash
bunx grassroot add chart/custom-projection-mapAPI Reference
| Prop | Type | Default |
|---|---|---|
project | ((longitude: number, latitude: number) => readonly [number, number]) | undefined | — |