Symbol map
Place sized and colored circles on a map by longitude and latitude, alone on a basemap or over a choropleth.
A symbol map puts a circle on each place, sized by a value. It suits totals, such as an economy’s output or a country’s population, because the circle’s area carries the number and the size of the region underneath does not.
Use a choropleth for rates and shares that belong to a whole region, and a bubble chart when position should carry two more numbers instead of a location.
A basic symbol map
Symbols go in the points layer of a "map" spec: its own data, and longitude and latitude channels naming the coordinate fields. size maps a number to the circle’s area, so the radius grows with its square root, and a size key of nested circles explains the scale. With a points layer the map needs no data of its own: data: [] and no color channel draw the states as a plain basemap.
{
"type": "map",
"geo": {
"features": {/* TopoJSON, 170 arcs; Copy includes it */},
"projection": "albersUsa"
},
"data": [],
"encoding": {
"key": {
"field": "id",
"type": "nominal"
}
},
"points": {
"data": [
{
"state": "California",
"label": "CA",
"gdp": 3.9,
"pop": 39,
"lon": -119.5,
"lat": 37.23
},
{
"state": "Texas",
"label": "TX",
"gdp": 2.6,
"pop": 30.5,
"lon": -99.28,
"lat": 31.47
},
{
"state": "New York",
"label": "NY",
"gdp": 2.1,
"pop": 19.6,
"lon": -75.53,
"lat": 42.97
},
{
"state": "Florida",
"label": "FL",
"gdp": 1.6,
"pop": 22.6,
"lon": -82.5,
"lat": 28.67
},
{
"state": "Illinois",
"label": "IL",
"gdp": 1.1,
"pop": 12.5,
"lon": -89.21,
"lat": 40.02
},
{
"state": "Pennsylvania",
"label": "PA",
"gdp": 1,
"pop": 12.9,
"lon": -77.78,
"lat": 40.89
},
{
"state": "Ohio",
"label": "OH",
"gdp": 0.9,
"pop": 11.8,
"lon": -82.78,
"lat": 40.28
},
{
"state": "Georgia",
"label": "GA",
"gdp": 0.8,
"pop": 11,
"lon": -83.4,
"lat": 32.57
},
{
"state": "New Jersey",
"label": "NJ",
"gdp": 0.8,
"pop": 9.3,
"lon": -74.64,
"lat": 40.2
},
{
"state": "Washington",
"label": "WA",
"gdp": 0.8,
"pop": 7.8,
"lon": -120.41,
"lat": 47.36
}
],
"longitude": {
"field": "lon",
"type": "quantitative"
},
"latitude": {
"field": "lat",
"type": "quantitative"
},
"size": {
"field": "gdp",
"type": "quantitative",
"title": "GDP ($ trillions)"
},
"key": {
"field": "label",
"type": "nominal"
},
"tooltip": [
{
"field": "state",
"type": "nominal",
"title": "State"
},
{
"field": "gdp",
"type": "quantitative",
"title": "GDP ($ trillions)"
},
{
"field": "pop",
"type": "quantitative",
"title": "Population (millions)"
}
]
},
"chrome": {
"title": "California's economy is half again the size of Texas's",
"subtitle": "GDP of the ten largest state economies, 2023 ($ trillions)"
}
}import { GeoMap } from "@opendata-ai/openchart-react";
import type { GeoMapSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const spec: GeoMapSpec = {
"type": "map",
"geo": {
"features": {/* TopoJSON, 170 arcs; Copy includes it */},
"projection": "albersUsa"
},
"data": [],
"encoding": {
"key": {
"field": "id",
"type": "nominal"
}
},
"points": {
"data": [/* 10 rows, as in the Spec tab; Copy includes them */],
"longitude": {
"field": "lon",
"type": "quantitative"
},
"latitude": {
"field": "lat",
"type": "quantitative"
},
"size": {
"field": "gdp",
"type": "quantitative",
"title": "GDP ($ trillions)"
},
"key": {
"field": "label",
"type": "nominal"
},
"tooltip": [
{
"field": "state",
"type": "nominal",
"title": "State"
},
{
"field": "gdp",
"type": "quantitative",
"title": "GDP ($ trillions)"
},
{
"field": "pop",
"type": "quantitative",
"title": "Population (millions)"
}
]
},
"chrome": {
"title": "California's economy is half again the size of Texas's",
"subtitle": "GDP of the ten largest state economies, 2023 ($ trillions)"
}
};
export function Example() {
return <GeoMap spec={spec} />;
}
<script setup lang="ts">
import { GeoMap } from "@opendata-ai/openchart-vue";
import type { GeoMapSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const spec: GeoMapSpec = {
"type": "map",
"geo": {
"features": {/* TopoJSON, 170 arcs; Copy includes it */},
"projection": "albersUsa"
},
"data": [],
"encoding": {
"key": {
"field": "id",
"type": "nominal"
}
},
"points": {
"data": [/* 10 rows, as in the Spec tab; Copy includes them */],
"longitude": {
"field": "lon",
"type": "quantitative"
},
"latitude": {
"field": "lat",
"type": "quantitative"
},
"size": {
"field": "gdp",
"type": "quantitative",
"title": "GDP ($ trillions)"
},
"key": {
"field": "label",
"type": "nominal"
},
"tooltip": [
{
"field": "state",
"type": "nominal",
"title": "State"
},
{
"field": "gdp",
"type": "quantitative",
"title": "GDP ($ trillions)"
},
{
"field": "pop",
"type": "quantitative",
"title": "Population (millions)"
}
]
},
"chrome": {
"title": "California's economy is half again the size of Texas's",
"subtitle": "GDP of the ten largest state economies, 2023 ($ trillions)"
}
};
</script>
<template>
<GeoMap :spec="spec" />
</template>
<script lang="ts">
import { GeoMap } from "@opendata-ai/openchart-svelte";
import type { GeoMapSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const spec: GeoMapSpec = {
"type": "map",
"geo": {
"features": {/* TopoJSON, 170 arcs; Copy includes it */},
"projection": "albersUsa"
},
"data": [],
"encoding": {
"key": {
"field": "id",
"type": "nominal"
}
},
"points": {
"data": [/* 10 rows, as in the Spec tab; Copy includes them */],
"longitude": {
"field": "lon",
"type": "quantitative"
},
"latitude": {
"field": "lat",
"type": "quantitative"
},
"size": {
"field": "gdp",
"type": "quantitative",
"title": "GDP ($ trillions)"
},
"key": {
"field": "label",
"type": "nominal"
},
"tooltip": [
{
"field": "state",
"type": "nominal",
"title": "State"
},
{
"field": "gdp",
"type": "quantitative",
"title": "GDP ($ trillions)"
},
{
"field": "pop",
"type": "quantitative",
"title": "Population (millions)"
}
]
},
"chrome": {
"title": "California's economy is half again the size of Texas's",
"subtitle": "GDP of the ten largest state economies, 2023 ($ trillions)"
}
};
</script>
<GeoMap {spec} />
import { createGeoMap } from "@opendata-ai/openchart-vanilla";
import type { GeoMapSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const spec: GeoMapSpec = {
"type": "map",
"geo": {
"features": {/* TopoJSON, 170 arcs; Copy includes it */},
"projection": "albersUsa"
},
"data": [],
"encoding": {
"key": {
"field": "id",
"type": "nominal"
}
},
"points": {
"data": [/* 10 rows, as in the Spec tab; Copy includes them */],
"longitude": {
"field": "lon",
"type": "quantitative"
},
"latitude": {
"field": "lat",
"type": "quantitative"
},
"size": {
"field": "gdp",
"type": "quantitative",
"title": "GDP ($ trillions)"
},
"key": {
"field": "label",
"type": "nominal"
},
"tooltip": [
{
"field": "state",
"type": "nominal",
"title": "State"
},
{
"field": "gdp",
"type": "quantitative",
"title": "GDP ($ trillions)"
},
{
"field": "pop",
"type": "quantitative",
"title": "Population (millions)"
}
]
},
"chrome": {
"title": "California's economy is half again the size of Texas's",
"subtitle": "GDP of the ten largest state economies, 2023 ($ trillions)"
}
};
const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createGeoMap(container, spec);
These datasets name states and countries without coordinates, so each symbol sits at the center of its state’s outline, worked out from the same atlas the map draws. The choropleth page shows how to pass an atlas in your own code. Larger circles draw first, so a small one is never hidden behind a large one.
Color as a second value
color on the points layer maps a second field to the fill, with its own legend and a scale separate from any region colors. Here size is GDP and color is population. legend.position: "bottom-right" puts the color legend and the size key in the right-hand gutter, aligned to the bottom.
A world symbol map
The same layer works on a world map. Here the basemap is the land object of world-atlas, all land as one shape with no country borders. projection: "equalEarth" keeps areas true to size.
Symbols over a choropleth
A spec can carry both layers: data and the color channel color the regions, and the points layer draws on top. Each layer keeps its own legend, so a rate per state and a total per state read together.
State GDP over the unemployment rate. This chart is drawn in the browser.
{
"type": "map",
"geo": {
"features": {/* TopoJSON, 181 arcs; Copy includes it */},
"projection": "albersUsa"
},
"data": [
{
"id": "01",
"rate": 2.7
},
{
"id": "02",
"rate": 4.8
},
{
"id": "04",
"rate": 4.7
},
{
"id": "05",
"rate": 4.2
},
{
"id": "06",
"rate": 5.3
},
{
"id": "08",
"rate": 3.8
},
// … 45 more rows; Copy includes them
],
"encoding": {
"key": {
"field": "id",
"type": "nominal"
},
"color": {
"field": "rate",
"type": "quantitative",
"format": ".1f",
"title": "Unemployment rate (%)"
}
},
"points": {
"data": [
{
"state": "California",
"label": "CA",
"gdp": 3.9,
"pop": 39,
"lon": -119.5,
"lat": 37.23
},
{
"state": "Texas",
"label": "TX",
"gdp": 2.6,
"pop": 30.5,
"lon": -99.28,
"lat": 31.47
},
{
"state": "New York",
"label": "NY",
"gdp": 2.1,
"pop": 19.6,
"lon": -75.53,
"lat": 42.97
},
{
"state": "Florida",
"label": "FL",
"gdp": 1.6,
"pop": 22.6,
"lon": -82.5,
"lat": 28.67
},
{
"state": "Illinois",
"label": "IL",
"gdp": 1.1,
"pop": 12.5,
"lon": -89.21,
"lat": 40.02
},
{
"state": "Pennsylvania",
"label": "PA",
"gdp": 1,
"pop": 12.9,
"lon": -77.78,
"lat": 40.89
},
{
"state": "Ohio",
"label": "OH",
"gdp": 0.9,
"pop": 11.8,
"lon": -82.78,
"lat": 40.28
},
{
"state": "Georgia",
"label": "GA",
"gdp": 0.8,
"pop": 11,
"lon": -83.4,
"lat": 32.57
},
{
"state": "New Jersey",
"label": "NJ",
"gdp": 0.8,
"pop": 9.3,
"lon": -74.64,
"lat": 40.2
},
{
"state": "Washington",
"label": "WA",
"gdp": 0.8,
"pop": 7.8,
"lon": -120.41,
"lat": 47.36
}
],
"longitude": {
"field": "lon",
"type": "quantitative"
},
"latitude": {
"field": "lat",
"type": "quantitative"
},
"size": {
"field": "gdp",
"type": "quantitative",
"title": "GDP ($ trillions)"
},
"key": {
"field": "label",
"type": "nominal"
},
"tooltip": [
{
"field": "state",
"type": "nominal",
"title": "State"
},
{
"field": "gdp",
"type": "quantitative",
"title": "GDP ($ trillions)"
},
{
"field": "pop",
"type": "quantitative",
"title": "Population (millions)"
}
]
},
"chrome": {
"title": "Eight of the ten largest state economies have unemployment above 4%",
"subtitle": "Unemployment rate (%) by state, with GDP of the ten largest state economies"
}
}import { GeoMap } from "@opendata-ai/openchart-react";
import type { GeoMapSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 51 rows; Copy includes them */];
const spec: GeoMapSpec = {
data,
"type": "map",
"geo": {
"features": {/* TopoJSON, 181 arcs; Copy includes it */},
"projection": "albersUsa"
},
"encoding": {
"key": {
"field": "id",
"type": "nominal"
},
"color": {
"field": "rate",
"type": "quantitative",
"format": ".1f",
"title": "Unemployment rate (%)"
}
},
"points": {
"data": [/* 10 rows, as in the Spec tab; Copy includes them */],
"longitude": {
"field": "lon",
"type": "quantitative"
},
"latitude": {
"field": "lat",
"type": "quantitative"
},
"size": {
"field": "gdp",
"type": "quantitative",
"title": "GDP ($ trillions)"
},
"key": {
"field": "label",
"type": "nominal"
},
"tooltip": [
{
"field": "state",
"type": "nominal",
"title": "State"
},
{
"field": "gdp",
"type": "quantitative",
"title": "GDP ($ trillions)"
},
{
"field": "pop",
"type": "quantitative",
"title": "Population (millions)"
}
]
},
"chrome": {
"title": "Eight of the ten largest state economies have unemployment above 4%",
"subtitle": "Unemployment rate (%) by state, with GDP of the ten largest state economies"
}
};
export function Example() {
return <GeoMap spec={spec} />;
}
<script setup lang="ts">
import { GeoMap } from "@opendata-ai/openchart-vue";
import type { GeoMapSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 51 rows; Copy includes them */];
const spec: GeoMapSpec = {
data,
"type": "map",
"geo": {
"features": {/* TopoJSON, 181 arcs; Copy includes it */},
"projection": "albersUsa"
},
"encoding": {
"key": {
"field": "id",
"type": "nominal"
},
"color": {
"field": "rate",
"type": "quantitative",
"format": ".1f",
"title": "Unemployment rate (%)"
}
},
"points": {
"data": [/* 10 rows, as in the Spec tab; Copy includes them */],
"longitude": {
"field": "lon",
"type": "quantitative"
},
"latitude": {
"field": "lat",
"type": "quantitative"
},
"size": {
"field": "gdp",
"type": "quantitative",
"title": "GDP ($ trillions)"
},
"key": {
"field": "label",
"type": "nominal"
},
"tooltip": [
{
"field": "state",
"type": "nominal",
"title": "State"
},
{
"field": "gdp",
"type": "quantitative",
"title": "GDP ($ trillions)"
},
{
"field": "pop",
"type": "quantitative",
"title": "Population (millions)"
}
]
},
"chrome": {
"title": "Eight of the ten largest state economies have unemployment above 4%",
"subtitle": "Unemployment rate (%) by state, with GDP of the ten largest state economies"
}
};
</script>
<template>
<GeoMap :spec="spec" />
</template>
<script lang="ts">
import { GeoMap } from "@opendata-ai/openchart-svelte";
import type { GeoMapSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 51 rows; Copy includes them */];
const spec: GeoMapSpec = {
data,
"type": "map",
"geo": {
"features": {/* TopoJSON, 181 arcs; Copy includes it */},
"projection": "albersUsa"
},
"encoding": {
"key": {
"field": "id",
"type": "nominal"
},
"color": {
"field": "rate",
"type": "quantitative",
"format": ".1f",
"title": "Unemployment rate (%)"
}
},
"points": {
"data": [/* 10 rows, as in the Spec tab; Copy includes them */],
"longitude": {
"field": "lon",
"type": "quantitative"
},
"latitude": {
"field": "lat",
"type": "quantitative"
},
"size": {
"field": "gdp",
"type": "quantitative",
"title": "GDP ($ trillions)"
},
"key": {
"field": "label",
"type": "nominal"
},
"tooltip": [
{
"field": "state",
"type": "nominal",
"title": "State"
},
{
"field": "gdp",
"type": "quantitative",
"title": "GDP ($ trillions)"
},
{
"field": "pop",
"type": "quantitative",
"title": "Population (millions)"
}
]
},
"chrome": {
"title": "Eight of the ten largest state economies have unemployment above 4%",
"subtitle": "Unemployment rate (%) by state, with GDP of the ten largest state economies"
}
};
</script>
<GeoMap {spec} />
import { createGeoMap } from "@opendata-ai/openchart-vanilla";
import type { GeoMapSpec } from "@opendata-ai/openchart-core";
import "@opendata-ai/openchart-core/styles.css";
const data = [/* 51 rows; Copy includes them */];
const spec: GeoMapSpec = {
data,
"type": "map",
"geo": {
"features": {/* TopoJSON, 181 arcs; Copy includes it */},
"projection": "albersUsa"
},
"encoding": {
"key": {
"field": "id",
"type": "nominal"
},
"color": {
"field": "rate",
"type": "quantitative",
"format": ".1f",
"title": "Unemployment rate (%)"
}
},
"points": {
"data": [/* 10 rows, as in the Spec tab; Copy includes them */],
"longitude": {
"field": "lon",
"type": "quantitative"
},
"latitude": {
"field": "lat",
"type": "quantitative"
},
"size": {
"field": "gdp",
"type": "quantitative",
"title": "GDP ($ trillions)"
},
"key": {
"field": "label",
"type": "nominal"
},
"tooltip": [
{
"field": "state",
"type": "nominal",
"title": "State"
},
{
"field": "gdp",
"type": "quantitative",
"title": "GDP ($ trillions)"
},
{
"field": "pop",
"type": "quantitative",
"title": "Population (millions)"
}
]
},
"chrome": {
"title": "Eight of the ten largest state economies have unemployment above 4%",
"subtitle": "Unemployment rate (%) by state, with GDP of the ten largest state economies"
}
};
const container = document.getElementById("chart");
if (!container) throw new Error('Add <div id="chart"></div> to the page first.');
createGeoMap(container, spec);
Over time
points.time plays the points layer through periods, resizing and recoloring each symbol from scales fixed for the whole run. points.key is required with it, so each symbol can be followed from one period to the next. The time-lapse map page has an example.
Fields that matter
| Field | What it does |
|---|---|
points.data |
The rows for the symbols, separate from the map’s own data. |
points.longitude, points.latitude |
The fields holding each symbol’s coordinates. |
points.size |
A number mapped to circle area. |
points.color |
A field mapped to fill, nominal or quantitative, with its own scale. |
points.key |
A stable id for each symbol, used for events and to match symbols across updates. Required with points.time. |
points.time |
The period field the layer plays through. |
points.tooltip |
The fields shown when a reader hovers a symbol. |
geo.features |
The basemap topology, drawn under the symbols. |
legend.position |
Where the legends sit, such as "bottom-right". |
Related
- Choropleth for coloring the regions themselves.
- Geographic labels for naming the symbols on the map.
- Time-lapse map for symbols played through periods.
- Bubble for sized circles on two numeric axes.
- GeoMapSpec reference lists every map field.