Flow map
Curved arrows from place to place, as wide as their volume. Good for trade, migrations, deliveries and travel between places.
The smallest code that works. change the code, then press Run
In your framework
import { Chart } from 'nervure/react';
const spec = {
type: 'flowmap',
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: 'naturalEarth',
places: [
{ label: 'Tunis', lon: 10.2, lat: 36.8 },
{ label: 'Cairo', lon: 31.2, lat: 30 },
{ label: 'Lagos', lon: 3.4, lat: 6.5 },
{ label: 'Nairobi', lon: 36.8, lat: -1.3 },
{ label: 'Johannesburg', lon: 28, lat: -26.2 },
{ label: 'Paris', lon: 2.35, lat: 48.86 },
{ label: 'London', lon: -0.1, lat: 51.5 },
{ label: 'Istanbul', lon: 29, lat: 41 },
{ label: 'Moscow', lon: 37.6, lat: 55.8 },
{ label: 'Dubai', lon: 55.3, lat: 25.3 },
{ label: 'Mumbai', lon: 72.9, lat: 19.1 },
{ label: 'Beijing', lon: 116.4, lat: 39.9 },
{ label: 'Tokyo', lon: 139.7, lat: 35.7 },
{ label: 'Jakarta', lon: 106.8, lat: -6.2 },
{ label: 'Sydney', lon: 151.2, lat: -33.9 },
{ label: 'New York', lon: -74, lat: 40.7 },
{ label: 'Mexico City', lon: -99.1, lat: 19.4 },
{ label: 'Los Angeles', lon: -118.2, lat: 34 },
{ label: 'São Paulo', lon: -46.6, lat: -23.5 },
{ label: 'Buenos Aires', lon: -58.4, lat: -34.6 },
],
flows: [
{ from: 'Tunis', to: 'New York', value: 12 },
{ from: 'Tunis', to: 'Jakarta', value: 57 },
{ from: 'Tunis', to: 'Paris', value: 74 },
{ from: 'Tunis', to: 'Johannesburg', value: 58 },
{ from: 'Dubai', to: 'Moscow', value: 46 },
{ from: 'Dubai', to: 'New York', value: 120 },
{ from: 'Dubai', to: 'Cairo', value: 48 },
{ from: 'Dubai', to: 'Paris', value: 35 },
{ from: 'New York', to: 'Nairobi', value: 45 },
{ from: 'New York', to: 'Cairo', value: 45 },
{ from: 'New York', to: 'Dubai', value: 116 },
{ from: 'New York', to: 'Mumbai', value: 44 },
],
};
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 flowmap takes:
/** Curved arrows from place to place, as wide as their volume. */
interface FlowMapSpec extends MapBase {
type: 'flowmap';
places: MapPoint[];
flows: MapFlow[];
/** Arrow heads: true by default. */
arrows?: boolean;
/** The places the flows leave from, which can be switched off. */
legend?: boolean | LegendOptions;
onFlowClick?: (flow: MapFlow) => void;
}
interface MapBase extends Base {
geo?: FeatureCollection | Topology;
object?: string;
projection?: MapSpec['projection'];
rotate?: [number, number];
key?: string;
nameKey?: string;
/** Buttons, drag, and ctrl + wheel, as on `map`. */
zoom?: boolean;
}
interface MapPoint {
lon: number;
interface MapFlow {
/** `id` (else `label`) of a place. */
from: string;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