Globe
The Earth as a ball that turns when you drag it, with values, points and routes. Good for flights, trade and anything seen from far away.
The smallest code that works. change the code, then press Run
In your framework
import { Chart } from 'nervure/react';
const spec = {
type: 'map',
geo: {
type: 'Topology',
arcs: [
[[141, -3], [151, -10], [141, -9]],
[[141, -9], [141, -3]],
[[170, -44], [174, -41], [169, -47], [167, -46], [170, -44]],
[
[126, -32],
[115, -34],
[114, -22],
[132, -11],
[136, -12],
[136, -15],
[140, -18],
[143, -11],
[154, -28],
[150, -37],
[146, -39],
[141, -38],
[138, -33],
[136, -35],
[131, -31],
[126, -32],
],
[
[39, -5],
[41, -15],
[35, -20],
[35, -24],
[28, -33],
[20, -35],
[12, -18],
[14, -11],
[9, 4],
[4, 6],
[-8, 4],
[-18, 15],
[-16, 24],
[-6, 36],
[10, 37],
[10, 34],
[19, 30],
[22, 33],
[34, 31],
],
[[34, 31], [35, 30]],
[[35, 30], [33, 29], [43, 12], [51, 12], [39, -5]],
[[50, -12], [45, -26], [44, -17], [50, -12]],
[
[-123, 49],
[-134, 58],
[-147, 61],
[-165, 54],
[-157, 59],
[-166, 61],
[-161, 65],
[-168, 66],
[-162, 66],
[-167, 68],
[-157, 71],
[-96, 67],
[-94, 72],
[-87, 67],
[-86, 70],
[-81, 69],
[-93, 62],
[-95, 59],
[-92, 57],
[-82, 55],
[-80, 51],
[-77, 57],
[-78, 62],
[-74, 62],
[-68, 58],
[-65, 60],
[-56, 54],
[-71, 47],
[-65, 49],
[-64, 46],
[-60, 46],
[-67, 45],
[-76, 39],
[-76, 36],
[-81, 31],
[-80, 25],
[-86, 30],
[-97, 27],
[-96, 19],
[-87, 22],
[-89, 16],
[-83, 15],
[-82, 9],
[-77, 9],
],
[[-77, 9], [-78, 7]],
[[-78, 7], [-103, 18], [-114, 32], [-109, 23], [-112, 25], [-124, 40], [-123, 49]],
[[-88, 74], [-97, 77], [-81, 76], [-88, 74]],
[[-56, 51], [-53, 47], [-59, 48], [-56, 51]],
[[-79, 72], [-62, 67], [-68, 66], [-66, 62], [-78, 64], [-73, 68], [-90, 72], [-79, 72]],
[[-122, 74], [-116, 73], [-123, 71], [-126, 72], [-125, 74], [-122, 74]],
[[-107, 73], [-102, 69], [-119, 72], [-107, 73]],
[[-96, 81], [-86, 79], [-96, 81]],
[[-92, 82], [-62, 83], [-81, 76], [-89, 76], [-85, 78], [-87, 80], [-82, 80], [-92, 82]],
[
[-47, 83],
[-12, 81],
[-20, 80],
[-18, 80],
[-22, 77],
[-19, 74],
[-26, 70],
[-22, 70],
[-40, 65],
[-45, 60],
[-52, 64],
[-54, 67],
[-51, 70],
[-55, 70],
[-51, 71],
[-59, 76],
[-73, 78],
[-47, 83],
],
[[53, 42], [50, 45], [53, 47], [49, 46]],
[
[49, 46],
[48, 50],
[61, 51],
[61, 54],
[69, 55],
[87, 49],
[99, 52],
[118, 50],
[124, 53],
[131, 48],
[135, 48],
[131, 42],
],
[
[131, 42],
[127, 34],
[125, 40],
[118, 39],
[122, 37],
[119, 35],
[122, 29],
[116, 23],
[106, 20],
[109, 12],
[105, 9],
[100, 13],
[99, 9],
[104, 1],
[91, 23],
[80, 16],
[78, 8],
[73, 21],
[49, 30],
[52, 24],
[56, 26],
[60, 22],
[55, 17],
[43, 13],
[35, 30],
],
[[34, 31], [36, 37], [28, 37], [26, 39], [40, 41], [40, 43]],
[[40, 43], [49, 42]],
[[49, 42], [52, 37], [55, 41], [53, 42]],
[[141, -9], [131, -1], [141, -3]],
[[118, 4], [116, -4], [110, -3], [110, 2], [117, 7], [118, 4]],
[[123, 1], [120, -1], [123, -1], [123, -5], [121, -3], [120, -6], [120, 0], [123, 1]],
[[104, -1], [105, -6], [95, 5], [104, -1]],
[[142, 39], [140, 35], [131, 34], [130, 31], [140, 41], [142, 39]],
[[-58, -34], [-57, -37], [-65, -41], [-68, -52], [-75, -52], [-70, -20], [-81, -6], [-78, 7]],
[[-77, 9], [-72, 12], [-72, 9], [-70, 12], [-62, 11], [-54, 6]],
[[-54, 6], [-55, 2], [-52, 4]],
[[-52, 4], [-50, 0], [-35, -7], [-41, -22], [-48, -25], [-54, -34], [-58, -34]],
[[49, 46], [47, 45], [49, 42]],
[[40, 43], [37, 45], [39, 47], [34, 44], [32, 47], [28, 42]],
[[26, 42], [28, 42]],
[[26, 41], [26, 42]],
[
[26, 41],
[23, 40],
[22, 36],
[13, 46],
[18, 40],
[16, 38],
[9, 44],
[3, 43],
[-2, 37],
[-9, 37],
[-9, 43],
[-1, 44],
[-5, 49],
[8, 54],
[9, 57],
[11, 54],
[20, 54],
[23, 59],
[29, 60],
[21, 61],
[24, 66],
[18, 63],
[16, 56],
[6, 59],
[5, 62],
[15, 68],
[28, 71],
[41, 67],
[33, 67],
[37, 64],
[44, 66],
[43, 69],
[69, 68],
[67, 71],
[70, 73],
[73, 72],
[72, 66],
[75, 73],
[82, 72],
[81, 74],
[104, 78],
[114, 76],
[109, 74],
[127, 74],
[131, 71],
[140, 73],
[180, 69],
[180, 65],
[177, 65],
[179, 62],
[164, 60],
[157, 51],
[156, 57],
[164, 63],
[142, 59],
[135, 55],
[141, 53],
[140, 48],
[131, 42],
],
[[54, 74], [69, 77], [58, 74], [55, 72], [58, 71], [52, 71], [54, 74]],
[[-175, 67], [-170, 66], [-173, 64], [-180, 65], [-180, 69], [-175, 67]],
[[15, 80], [22, 79], [16, 77], [10, 80], [15, 80]],
[[-3, 53], [-5, 59], [2, 53], [-5, 50], [-3, 53]],
[[-15, 66], [-19, 63], [-24, 66], [-15, 66]],
],
objects: {
continents: {
type: 'GeometryCollection',
geometries: [
{ type: 'MultiPolygon', id: 'oceania', properties: { name: 'Oceania' }, arcs: [[[0, 1]], [[2]], [[3]]] },
{ type: 'MultiPolygon', id: 'africa', properties: { name: 'Africa' }, arcs: [[[4, 5, 6]], [[7]]] },
{
type: 'MultiPolygon',
id: 'north-america',
properties: { name: 'North America' },
arcs: [[[8, 9, 10]], [[11]], [[12]], [[13]], [[14]], [[15]], [[16]], [[17]], [[18]]],
},
{
type: 'MultiPolygon',
id: 'asia',
properties: { name: 'Asia' },
arcs: [[[19, 20, 21, -6, 22, 23, 24]], [[-2, 25]], [[26]], [[27]], [[28]], [[29]]],
},
{ type: 'MultiPolygon', id: 'south-america', properties: { name: 'South America' }, arcs: [[[30, -10, 31, 32, 33]]] },
{
type: 'MultiPolygon',
id: 'europe',
properties: { name: 'Europe' },
arcs: [[[-21, 34, -24, 35, -37, -38, 38]], [[39]], [[40]], [[41]], [[42]], [[43]]],
},
],
},
},
},
projection: 'orthographic',
rotate: [21, 20],
zoom: true,
color: ['#1d6a5e', '#2a9d8f', '#edb73b'],
values: { oceania: 25, africa: 53, 'north-america': 21, asia: 20, 'south-america': 64, europe: 57 },
routes: [
{ from: [10.2, 36.8], to: [2.35, 48.86], label: 'Paris' },
{ from: [10.2, 36.8], to: [-0.1, 51.5], label: 'London' },
{ from: [10.2, 36.8], to: [29, 41], label: 'Istanbul' },
{ from: [10.2, 36.8], to: [37.6, 55.8], label: 'Moscow' },
],
points: [{ label: 'Tunis', lon: 10.2, lat: 36.8 }],
};
export default function Example() {
return <Chart spec={spec} style={{ height: 340 }} />;
}Or import this chart alone: what each import weighs.
Options
Beside the fields shared by every chart (title, format, heading, export…), type map takes:
interface MapSpec extends Base {
type: 'map';
/** GeoJSON or TopoJSON. nervure ships no map data. */
geo: FeatureCollection | Topology;
/** Object to read in a TopoJSON file; the first one by default. */
object?: string;
/** `equalEarth` and `gallPeters` keep every place at its true size. */
projection?: 'mercator' | 'equirectangular' | 'naturalEarth' | 'equalEarth' | 'gallPeters' | 'conic' | 'orthographic';
/** Writes the area of a place in its tooltip. */
area?: boolean;
/** Longitude and latitude at the centre (`orthographic`). */
rotate?: [number, number];
/** Value of each feature, by `key`. */
values?: Record<string, number | null>;
/** Property that identifies a feature; its `id` by default. */
key?: string;
/** Property shown as its name. */
nameKey?: string;
/** Colour of the highest value, or a list from the lowest to the highest. */
color?: string | string[];
legend?: boolean;
points?: MapPoint[];
routes?: MapRoute[];
/** Buttons, drag, and ctrl + wheel. */
zoom?: boolean;
onFeatureClick?: (id: string, feature: GeoFeature) => void;
onPointClick?: (point: MapPoint) => void;
}
interface MapPoint {
lon: number;
interface MapRoute {
from: [number, number];Style it
- Colours:
theme.palette,chart.setColor(name, colour), or--nervure-palettein your CSS. More - Marks:
[data-series="name"], parts:[data-part="axes"],legend,series. What you change is kept in exports. - Movement:
animation: falsedraws at once. More - Files:
chart.download('png'),svg,csv. More