Spike map
A spike at each place, as tall as its value. Good for populations and amounts by place, without hiding the map.
The smallest code that works. change the code, then press Run
In your framework
import { Chart } from 'nervure/react';
const spec = {
type: 'spikemap',
geo: {
type: 'Topology',
transform: { scale: [0.01, 0.01], translate: [7.5, 30.2] },
arcs: [
[[261, 663], [18, 4], [-4, 7]],
[[275, 674], [10, -7], [-7, -6]],
[[278, 661], [-2, 0]],
[[276, 661], [-5, -3]],
[[271, 658], [-2, -6], [-5, 2], [-5, -4]],
[[259, 650], [-9, 9], [12, 1], [-1, 3]],
[[278, 661], [4, -6], [10, -3]],
[[292, 652], [-9, -14], [5, -1], [-3, -8]],
[[285, 629], [-10, -4], [2, 5], [-11, 3], [-2, 7], [-3, -2], [-7, 4]],
[[254, 642], [5, 8]],
[[271, 658], [5, -1], [0, 4]],
[[88, 615], [28, 7], [15, -2], [13, 5]],
[
[144, 625],
[5, -10],
[-5, -4],
[10, -7],
[0, -9],
[12, -6],
[1, -7],
[-15, -18],
[3, -16],
[-4, 2],
],
[[151, 550], [-34, 9], [-5, -4], [-1, -9], [-18, 1], [-8, -5]],
[[85, 542], [1, 5], [-10, 6], [-1, 16], [10, 21], [-4, 7], [8, 14], [-1, 4]],
[[268, 594], [8, 3], [0, 6], [12, 1], [-1, 14]],
[[287, 618], [10, -3], [4, 4], [2, -4]],
[[303, 615], [-6, -21], [6, -16], [-8, 3], [8, -3], [15, -20]],
[[318, 558], [-6, -5], [3, -7], [-8, -1], [-8, -12], [1, -5], [8, 2], [3, -3]],
[[311, 527], [-4, -7], [-7, 1], [-5, 7], [-8, -1], [-7, 6], [1, 6]],
[[281, 539], [-15, 22], [10, 17], [-8, 16]],
[
[221, 408],
[5, -1],
[-4, 7],
[14, 3],
[6, 10],
[2, -2],
[12, 8],
[-9, 1],
[-10, 7],
[19, 41],
],
[[256, 482], [0, 4], [9, 8], [7, 1]],
[
[272, 495],
[21, -6],
[16, 9],
[-3, 5],
[7, 3],
[8, -4],
[5, 6],
[7, -13],
[8, 4],
[5, -9],
[6, -1],
],
[
[352, 489],
[2, -5],
[-12, -8],
[0, -9],
[-17, -15],
[-2, -7],
[-9, -2],
[-5, -9],
[-14, -4],
[-10, -10],
[-6, 2],
[-2, -5],
[-8, -1],
[-17, -17],
],
[[252, 399], [-9, 2], [-3, -4], [-8, 7], [-7, -2], [-4, 6]],
[[347, 446], [15, 0], [-7, -5], [-8, 5]],
[[362, 448], [5, 8], [5, -2], [3, 9], [7, -3], [-5, -2], [3, -5], [-18, -5]],
[
[88, 615],
[3, 7],
[-20, 3],
[-6, 5],
[30, 12],
[4, 8],
[-6, 6],
[24, 6],
[-5, 3],
[2, 9],
[14, 1],
[10, 6],
],
[
[138, 681],
[4, -2],
[1, -7],
[7, -3],
[-9, -11],
[12, -3],
[-1, -8],
[6, -7],
[-1, -7],
[-5, -7],
],
[[152, 626], [-8, -1]],
[[281, 539], [-10, -4], [5, -5], [-10, -14], [4, -4], [-3, -5], [5, -12]],
[
[256, 482],
[-5, 2],
[-4, 16],
[-10, -3],
[-12, 1],
[-11, 8],
[-9, 2],
[-2, 6],
[-7, 2],
[4, 5],
[-4, 8],
],
[[196, 529], [-19, 23], [13, -3], [14, 5], [-6, 5], [4, 5], [-3, 6], [27, 21]],
[[226, 591], [5, 0], [2, -5], [5, 2], [16, -8], [2, 11], [8, -3], [4, 6]],
[[151, 550], [-5, -2], [3, -5], [18, -1], [1, -6], [9, -1], [7, -7]],
[
[184, 528],
[-13, -9],
[-6, -10],
[12, -7],
[-3, -2],
[0, -6],
[8, -6],
[-5, -6],
[-24, -8],
[3, -7],
[-14, -6],
],
[[142, 461], [-33, -18], [-27, 10]],
[[82, 453], [-8, 19], [7, 3], [5, 15], [12, 14], [-17, 8], [0, 9], [8, 6], [-4, 15]],
[[311, 527], [13, 2], [7, -7], [13, 12], [9, 1]],
[[353, 535], [5, -4], [-4, -18], [13, -10], [-5, -1], [-10, -13]],
[[254, 642], [-2, 4], [-12, -11], [-4, 3]],
[[236, 638], [-8, 7], [-1, 8], [-3, -2], [-10, 5], [-7, 8]],
[[207, 664], [20, 5], [5, 8], [18, -5]],
[[250, 672], [-4, -8], [11, 3], [4, -4]],
[[221, 408], [-16, -1]],
[
[205, 407],
[1, 10],
[-5, 1],
[-6, 10],
[-14, 2],
[4, 6],
[-10, 2],
[1, 10],
[-10, 4],
[-9, -4],
[-15, 13],
],
[[184, 528], [12, 1]],
[[24, 323], [11, 3], [50, 32], [21, 16], [9, 12]],
[[115, 386], [60, 13]],
[
[175, 399],
[10, -8],
[-9, -5],
[-1, -13],
[10, -22],
[9, -3],
[2, -6],
[8, 2],
[2, -5],
[6, 0],
[-13, -9],
[13, -8],
[9, -14],
],
[[221, 308], [8, -6], [12, -1], [0, -14]],
[
[241, 287],
[3, -7],
[7, -2],
[-8, -4],
[4, -8],
[-9, -12],
[8, -5],
[-1, -4],
[-24, 15],
[-50, -15],
[-85, -15],
],
[[86, 230], [-4, 32], [-20, 23], [0, 5], [-29, 9], [-8, 14], [-1, 10]],
[[138, 681], [20, 15]],
[[158, 696], [3, -11], [8, 0], [6, -14], [13, -6], [-4, -8], [6, -5], [17, 12]],
[[236, 638], [-12, -13]],
[[224, 625], [-9, -4], [-22, 5], [-16, -12], [-2, 3], [-14, 0], [-9, 9]],
[
[241, 287],
[25, 1],
[33, 16],
[12, -4],
[-9, -5],
[4, -4],
[48, -1],
[-2, -7],
[9, -16],
[2, -15],
[-5, -4],
[6, -15],
[9, -15],
[11, 1],
[-16, -8],
[-3, -6],
],
[
[365, 205],
[-29, -14],
[-7, -11],
[-14, -3],
[-4, -5],
[2, -4],
[-10, -14],
[-14, 0],
[-11, -7],
[-15, -19],
[16, -39],
[2, -19],
[-4, -10],
[-33, -42],
[-38, -15],
[-50, 186],
[-70, 41],
],
[[252, 399], [2, -15], [7, -15], [17, -15], [20, -9], [-6, -1]],
[[292, 344], [-14, -21], [-12, -2], [-9, -8], [-36, -5]],
[[175, 399], [27, 4], [3, 4]],
[
[158, 696],
[14, 8],
[3, -2],
[51, 13],
[10, -2],
[3, -5],
[-11, -4],
[3, -10],
[11, 3],
[1, 6],
[-11, 0],
[7, 5],
[9, -3],
[9, 2],
[21, -9],
[-13, -2],
[-1, -2],
[5, -3],
[3, 4],
[0, -4],
],
[[272, 691], [-13, -1], [-9, -18]],
[[272, 691], [-4, -6], [7, -11]],
[
[292, 652],
[12, 4],
[7, 12],
[15, 3],
[15, 10],
[0, 4],
[12, 4],
[11, -21],
[-17, -15],
[-16, -27],
[-23, -6],
[-5, -5],
],
[[287, 618], [-2, 11]],
[[318, 558], [15, 1], [0, -8], [22, -8], [-2, -8]],
[[224, 625], [1, -9], [-16, -10], [13, -6], [4, -9]],
[[115, 386], [-30, -1], [-2, 11], [-18, 4], [-11, 13], [10, 20]],
[[64, 433], [8, 5], [6, 8], [-4, 3], [8, 4]],
[
[292, 344],
[15, 2],
[-2, -3],
[4, 0],
[-2, 2],
[15, 6],
[2, -10],
[-6, -8],
[2, -4],
[8, -2],
[15, 6],
[0, 13],
[4, -4],
[3, 3],
[11, -11],
[2, -6],
[-4, -4],
[5, -5],
[-4, -3],
[3, 1],
[16, -9],
[-16, 4],
[4, -11],
[27, -3],
[-11, 9],
[23, -10],
[-8, -51],
[12, -14],
[-1, -7],
[-44, -20],
],
[
[323, 356],
[1, 13],
[19, -1],
[-4, 3],
[17, -8],
[0, -4],
[-17, -16],
[-6, 11],
[-7, -4],
[-3, 6],
],
[[24, 323], [-22, 37], [4, 21], [-3, 6], [8, 4], [4, 9], [8, -3], [9, 4], [4, 20], [28, 12]],
],
objects: {
governorates: {
type: 'GeometryCollection',
geometries: [
{ type: 'MultiPolygon', id: 'TN-11', properties: { name: 'Tunis' }, arcs: [[[0, 1, 2, 3, 4, 5]]] },
{ type: 'MultiPolygon', id: 'TN-13', properties: { name: 'Ben Arous' }, arcs: [[[-3, 6, 7, 8, 9, -5, 10]]] },
{ type: 'MultiPolygon', id: 'TN-33', properties: { name: 'El Kef' }, arcs: [[[11, 12, 13, 14]]] },
{ type: 'MultiPolygon', id: 'TN-51', properties: { name: 'Sousse' }, arcs: [[[15, 16, 17, 18, 19, 20]]] },
{ type: 'MultiPolygon', id: 'TN-61', properties: { name: 'Sfax' }, arcs: [[[21, 22, 23, 24, 25]], [[26]], [[27]]] },
{ type: 'MultiPolygon', id: 'TN-32', properties: { name: 'Jendouba' }, arcs: [[[-12, 28, 29, 30]]] },
{ type: 'MultiPolygon', id: 'TN-41', properties: { name: 'Kairouan' }, arcs: [[[-21, 31, -23, 32, 33, 34]]] },
{ type: 'MultiPolygon', id: 'TN-42', properties: { name: 'Kasserine' }, arcs: [[[-14, 35, 36, 37, 38]]] },
{ type: 'MultiPolygon', id: 'TN-53', properties: { name: 'Mahdia' }, arcs: [[[-20, 39, 40, -24, -32]]] },
{ type: 'MultiPolygon', id: 'TN-14', properties: { name: 'Manouba' }, arcs: [[[-6, -10, 41, 42, 43, 44]]] },
{ type: 'MultiPolygon', id: 'TN-43', properties: { name: 'Sidi Bouzid' }, arcs: [[[-22, 45, 46, -37, 47, -33]]] },
{ type: 'MultiPolygon', id: 'TN-73', properties: { name: 'Kébili' }, arcs: [[[48, 49, 50, 51, 52, 53]]] },
{ type: 'MultiPolygon', id: 'TN-31', properties: { name: 'Béja' }, arcs: [[[-30, 54, 55, -43, 56, 57]]] },
{ type: 'MultiPolygon', id: 'TN-83', properties: { name: 'Tataouine' }, arcs: [[[-53, 58, 59]]] },
{ type: 'MultiPolygon', id: 'TN-81', properties: { name: 'Gabès' }, arcs: [[[-26, 60, 61, -51, 62, -46]]] },
{ type: 'MultiPolygon', id: 'TN-23', properties: { name: 'Bizerte' }, arcs: [[[-44, -56, 63, 64]]] },
{ type: 'MultiPolygon', id: 'TN-12', properties: { name: 'Ariana' }, arcs: [[[-1, -45, -65, 65]]] },
{ type: 'MultiPolygon', id: 'TN-21', properties: { name: 'Nabeul' }, arcs: [[[-8, 66, -17, 67]]] },
{ type: 'MultiPolygon', id: 'TN-52', properties: { name: 'Monastir' }, arcs: [[[-19, 68, -40]]] },
{ type: 'MultiPolygon', id: 'TN-34', properties: { name: 'Siliana' }, arcs: [[[-13, -31, -58, 69, -34, -48, -36]]] },
{ type: 'MultiPolygon', id: 'TN-22', properties: { name: 'Zaghouan' }, arcs: [[[-9, -68, -16, -35, -70, -57, -42]]] },
{ type: 'MultiPolygon', id: 'TN-71', properties: { name: 'Gafsa' }, arcs: [[[-38, -47, -63, -50, 70, 71]]] },
{ type: 'MultiPolygon', id: 'TN-82', properties: { name: 'Médenine' }, arcs: [[[-52, -62, 72, -59]], [[73]]] },
{ type: 'MultiPolygon', id: 'TN-72', properties: { name: 'Tozeur' }, arcs: [[[-49, 74, -71]]] },
],
},
},
},
values: {
'TN-11': 536,
'TN-13': 412,
'TN-33': 198,
'TN-51': 500,
'TN-61': 155,
'TN-32': 150,
'TN-41': 626,
'TN-42': 552,
'TN-53': 241,
'TN-14': 263,
'TN-43': 235,
'TN-73': 234,
'TN-31': 954,
'TN-83': 65,
'TN-81': 635,
'TN-23': 44,
'TN-12': 436,
'TN-21': 262,
'TN-52': 276,
'TN-34': 739,
'TN-22': 55,
'TN-71': 450,
'TN-82': 600,
'TN-72': 462,
},
legend: true,
};
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 spikemap takes:
/** A spike at each place, as tall as its value. */
interface SpikeMapSpec extends MapBase {
type: 'spikemap';
/** Value of each feature, by `key`: its spike stands at its middle. */
values?: Record<string, number | null>;
points?: MapPoint[];
color?: string;
/** A spike of the largest value, with its figure. */
legend?: boolean;
onPointClick?: (point: MapPoint) => 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;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