Dot Density Map
What is a dot density map?
A dot density map, also known as a dot map or dot distribution map, is a thematic map that marks one dot for every fixed number of something, such as 1 dot = 10,000 cattle, inside the area where those things were counted. Crowded dots mean high density; scattered dots mean low density.

Cattle (orange) and hogs (blue) on US farms, one dot per 10,000 head, from the 2022 Census of Agriculture. Try the interactive version, and change the dot value.
- Each dot stands for the same number, called the dot value. An area's dot count gives its total, and how closely its dots are packed gives its density.
- Map counts, not rates. Dots suit totals such as animals, people or farms, never percentages or averages.
- The dot value and dot size decide what the map can show: set them so the busiest areas just begin to merge.
- Unless extra data guides them, the dots go at random places within each area, so a dot is never an address.
- Two or more colours turn it into a categorical dot map. Shuffle the drawing order so that no colour hides another.
How to read a dot density map
The diagram below zooms into eight counties in eastern North Carolina, the area with the highest density of hogs on the national map, at one dot per 10,000 head.
- Find the dot value in the legend. Here 1 dot = 10,000 head, and blue means hogs.
- Count and multiply to estimate a total. Duplin County has 188 blue dots, so about 1.9 million hogs; the census counted 1,884,573. Few people count dots in practice, and readers tend to underestimate totals in crowded areas.
- Compare how closely the dots are packed to judge density. Duplin has about 2,300 hogs per square mile of land, Onslow under 200.
- Look at what has no dots. Bladen County has 4,358 cattle: less than half a dot, so it rounds to none. A blank area can mean small, not zero.
- Remember the dots aren't farms. The census gives one figure per county, so each dot is put at a random place inside its county. Clusters within one county are chance; only patterns across many counties reflect the data.
A dot density map example: cattle and hogs in the United States
The map at the top of this page uses the 2022 Census of Agriculture from the US Department of Agriculture (USDA), which counted 87,954,742 cattle and calves and 73,817,751 hogs and pigs on US farms on 31 December 2022. The demo maps every county of the 48 contiguous states.
The two animals make very different patterns:
- Hogs are concentrated. Iowa alone had 23.8 million, 32% of the US total. In North Carolina, the eight counties in the diagram held 70% of the state's hogs on 12% of its land. Half of the 2,368 counties with a published hog figure had fewer than 240 hogs.
- Cattle are spread out. 3,005 counties had a published figure above zero. There are clusters in the Texas Panhandle, where Deaf Smith County alone had 700,069, and in California's Central Valley, where Tulare County had 1,080,665, the most of any county.
A dot density map suits both. Hogs show up as tight blue clusters, and the cattle as a broad orange spread. A choropleth of head per square mile would show the same density, but in one colour per animal, so the two patterns would need two maps.
How to describe a dot density map
Name the dot value, the main concentrations, the empty areas and anything surprising. For example: "At one dot per 10,000 head, hogs cluster tightly in Iowa, southern Minnesota and eastern North Carolina, while cattle spread across the Great Plains and the West, densest in the Texas Panhandle and California's Central Valley. Nevada and much of Arizona show few dots of either colour."
Choosing the dot value and dot size
Each dot's dot value is the number of things it stands for, and its dot size is how big it is drawn. Together they decide how many dots there are and whether they merge. For the cattle and hogs data, by county:
| Dot value | Cattle dots | Hog dots | Counties with a figure but no dot |
|---|---|---|---|
| 1 dot = 1,000 head | 87,773 | 73,501 | 107 of 3,005 for cattle; 1,487 of 2,368 for hogs |
| 1 dot = 10,000 head | 8,727 | 7,301 | 705 for cattle; 1,807 for hogs |
| 1 dot = 50,000 head | 1,538 | 1,429 | 1,949 for cattle; 1,961 for hogs |
A common guideline from cartography is to choose the two together so that:
- the areas with the smallest counts still get two or three dots;
- the dots in the busiest areas just begin to touch.
Use a round dot value that readers can multiply in their heads, such as 1,000 or 10,000, and expect to try a few. Very uneven data, like the hogs above, can't meet both conditions: the smallest county with hogs had 3, and Duplin had 1,884,573. In that case, decide which matters more. A low dot value with small, see-through dots keeps the small counties; a high value with larger dots keeps the clusters readable.
Small dots also suggest precision. A map with 160,000 tiny dots looks as if it shows each farm, though every dot is a share of a county total.
Where to put the dots
Random placement, and the size of the areas
Most dot density maps place each area's dots at random inside it, spread evenly over its land. That is honest when the things counted really are spread through the area, and misleading when they aren't. The smaller the areas, the less a dot can stray.
Switch the demo from Counties to States to see the difference. With one figure per state, North Carolina's 819 hog dots (at 10,000 per dot) spread evenly from the Appalachians to the coast, so the eight counties in the diagram get about 12% of them. With county figures they get 70%.
Placing dots on a regular grid inside each area is worse than random: the density changes abruptly at every border, so the borders stand out more than the pattern.
Dasymetric placement
Dasymetric placement uses other data to keep dots off land where the thing can't be, and to weight them towards land where it's likely to be. For people, that means leaving out water, parks and uninhabited land, or placing dots by building footprints. For livestock, it could mean placing cattle on pasture and hogs near known farm sites. It needs a second dataset, and the dots remain estimates.
Missing and withheld counts
The Census of Agriculture withholds a county's figure, marked (D), when publishing it would reveal one farm's numbers. Across the demo's 3,108 counties and county-equivalents, 513 have a withheld hog figure and 46 a withheld cattle figure. The state total still includes them, so the demo spreads each state's leftover count over its withheld counties. In North Carolina, 263,909 hogs, about 26 dots at 10,000 per dot, are shared among 16 counties. Leaving them out would undercount the state, and putting them in a single county would invent a cluster.
Two or more colours: categorical dot maps
A categorical dot map uses one dot colour per category, such as cattle and hogs, two crops, or groups of people, so the mix of categories shows up in one map. Three things matter:
- Colours that stay distinct on the background and for colour-blind readers. Orange and blue work for most people; avoid red with green. More than four or five colours become hard to tell apart in small dots.
- The drawing order. Dots drawn later cover dots drawn earlier. If all the cattle are drawn after all the hogs, places with both look like cattle country. Use the demo's On top buttons to see this in the 482 counties that have both animals at 10,000 per dot. Shuffling the order mixes the colours fairly.
- The same dot value for every colour, so that equal numbers of dots mean equal counts. Different dot values in different colours are easily misread.
The same ideas apply to a single dot map of people, which is covered with US population data in the population density map guide.
One-to-one and one-to-many dot maps
The name covers two kinds of map:
- In a one-to-one dot map, each dot is one real thing at its real location, such as an earthquake or a shop. It is a map of points, and the position of each dot is the data.
- In a one-to-many dot map, each dot stands for many things counted in an area, as on this page. The count is the data; the position within the area is a guess.
"Dot density map" usually means the one-to-many kind. If you have exact locations, you don't need random placement. Plot the points themselves, and switch to a heatmap or a grid when there are too many to see.
When to use a dot density map
Use a dot density map for counts of things that are spread across the land, when the overall pattern matters more than the exact figure for each area.
| Map | What it shows | Use it when |
|---|---|---|
| Dot density map | A count, as dots of a fixed value placed inside each area | Showing where things are and how dense, and comparing two or three categories on one map |
| Choropleth map | A rate or average for each area, as a colour | Mapping percentages, rates per person, or densities, and reading each area's value |
| Proportional symbol map | A total for each area or place, as a sized circle | The count belongs at a point, such as a city, or readers must compare totals: like a bubble chart on a map |
| One-to-one point map | Each record at its real location | You have exact coordinates for every record |
| Grid map or heatmap | Counts or density on equal squares or hexagons | You have point data, or too many records to draw as dots |
Don't use a dot density map for averages, percentages or rates, such as yield per acre or the share of farms with hogs. There is no sensible way to draw "one dot per 2%". Use a choropleth for those.
Common dot density map mistakes
- Dots for a rate. Dot density maps need counts. Map rates and averages on a choropleth.
- A dot value too high. Small areas round to zero dots and look empty. At 10,000 head per dot, 705 counties with cattle get no dot.
- Dots that merge into blobs. In dense areas, dots that overlap completely hide how dense the area is. Use smaller dots, a higher dot value, or see-through dots.
- One colour always on top. Drawing one category after another hides the first wherever they overlap. Shuffle the drawing order.
- No dot value in the legend. Readers can't estimate a total without it. Show "1 dot = …" next to the colours.
- A projection that changes areas. Readers judge density from how closely dots are packed, so an area-distorting projection changes the density they see. Use an equal-area projection.
- Big areas with random dots. A dot placed at random in a large, mostly empty area looks like a real place. Use the smallest areas you have data for, or dasymetric placement.
How to create a dot density map in JavaScript, React or Angular
SciChart.js renders with WebGL, so a map of 160,000 dots stays smooth while you zoom and pan, and a new dot value appears straight away. The demo below draws all the dots in a single scatter series, coloured by animal, over the state borders.
Choose the dot value (1 dot =), the areas the dots are placed in (Dots in) and the drawing order (On top) with the buttons. Hover over a county to see its name and figures. Scroll to zoom, drag to pan, and double-click to reset.
Here is the code for this dot density map. The demo receives each county as a name, a state, its cattle and hog counts and an encoded outline, then decodes the outline into rings of [x, y] points in kilometres:
{
"name": "Duplin",
"state": "NC",
"cattle": 21940,
"hogs": 1884573,
"rings": [[[1601, 1499], [1631, 1503], [1637, 1501], …, [1607, 1449]]]
}
- JavaScript
- React
- Angular
// Create a JavaScript dot density map with SciChart.js: cattle and hogs on US farms, one dot per 1,000, 10,000
// or 50,000 head, in two colours, placed at random inside each county (or each state, to compare)
const {
SciChartSurface,
NumericAxis,
NumberRange,
XyDataSeries,
FastLineRenderableSeries,
XyScatterRenderableSeries,
SquarePointMarker,
EStrokePaletteMode,
BoxAnnotation,
NativeTextAnnotation,
ECoordinateMode,
EHorizontalAnchorPoint,
EVerticalAnchorPoint,
EMultiLineAlignment,
Thickness,
CustomChartModifier2D,
translateFromCanvasToSeriesViewRect,
MouseWheelZoomModifier,
ZoomPanModifier,
ZoomExtentsModifier,
SciChartJsNavyTheme,
parseColorToUIntArgb
} = SciChart;
// or, for npm, import { SciChartSurface, ... } from "scichart"
// The two things mapped, one colour each. Orange and blue stay distinct for most colour-blind readers.
const ANIMALS = [
{ key: "cattle", label: "Cattle and calves", color: "#F7A13B" },
{ key: "hogs", label: "Hogs and pigs", color: "#5CC8F5" }
];
// Dot values to choose from. Small dots for the low value, so the dense areas don't turn solid;
// bigger dots for the high values, so the few dots stay visible.
const DOT_STYLES = [
{ headPerDot: 1000, size: 1, alpha: "90" },
{ headPerDot: 10000, size: 2, alpha: "FF" },
{ headPerDot: 50000, size: 3, alpha: "FF" }
];
const WITHHELD = -1; // NASS withholds a county figure that would reveal one farm's numbers: "(D)"
const NO_FIGURE = -2; // no separate figure for this area (some independent cities)
// 1. DATA HELPERS (plain JavaScript, no SciChart code)
// Decode one outline from the encoded polyline format (the same idea as Google's polyline encoding):
// each number is the change from the previous point in whole kilometres, written in 5-bit chunks as characters.
function decodeOutline(encoded) {
const points = [];
let index = 0;
let x = 0;
let y = 0;
const nextNumber = () => {
let result = 0;
let shift = 0;
let chunk;
do {
chunk = encoded.charCodeAt(index++) - 63;
result |= (chunk & 0x1f) << shift;
shift += 5;
} while (chunk >= 0x20);
return result & 1 ? ~(result >> 1) : result >> 1;
};
while (index < encoded.length) {
x += nextNumber();
y += nextNumber();
points.push([x, y]);
}
return points;
}
// Cut an outline into triangles by ear clipping (repeatedly cut off a corner with no other point inside it).
// Random points are easy to place evenly inside a triangle, so the dots are placed triangle by triangle.
// For large or complex maps, use a tested library such as earcut, or triangulate once offline.
function triangulateRing(ring) {
const points = ring.slice();
let signedArea = 0;
points.forEach(([x1, y1], i) => {
const [x2, y2] = points[(i + 1) % points.length];
signedArea += x1 * y2 - x2 * y1;
});
if (signedArea < 0) points.reverse(); // make the ring counter-clockwise
const cross = (a, b, c) => (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]);
const isInside = (p, a, b, c) => cross(a, b, p) >= 0 && cross(b, c, p) >= 0 && cross(c, a, p) >= 0;
const remaining = points;
const triangles = []; // flat list: every three points make one triangle
while (remaining.length > 3) {
const n = remaining.length;
let earIndex = -1;
for (let i = 0; i < n && earIndex < 0; i++) {
const a = remaining[(i + n - 1) % n];
const b = remaining[i];
const c = remaining[(i + 1) % n];
if (cross(a, b, c) <= 0) continue; // not a convex corner
const blocked = remaining.some(
(p) => p !== a && p !== b && p !== c && !(p[0] === b[0] && p[1] === b[1]) && isInside(p, a, b, c)
);
if (!blocked) {
triangles.push(a, b, c);
earIndex = i;
}
}
if (earIndex < 0) {
// No ear found: drop a point that lies on a straight line, or stop
earIndex = remaining.findIndex((b, i) => cross(remaining[(i + n - 1) % n], b, remaining[(i + 1) % n]) === 0);
if (earIndex < 0) break;
}
remaining.splice(earIndex, 1);
}
if (remaining.length === 3) triangles.push(...remaining);
return triangles;
}
// Is the point inside the ring? (ray casting: count how many edges a horizontal line from the point crosses)
function isPointInRing(x, y, ring) {
let inside = false;
for (let i = 0, j = ring.length - 1; i < ring.length; j = i++) {
const [xi, yi] = ring[i];
const [xj, yj] = ring[j];
if (yi > y !== yj > y && x < ((xj - xi) * (y - yi)) / (yj - yi) + xi) inside = !inside;
}
return inside;
}
// Flatten rings into x and y arrays with NaN between rings, so one line series draws them all with gaps
function ringsToLine(rings, closeRings) {
const xValues = [];
const yValues = [];
rings.forEach((ring) => {
ring.forEach(([x, y]) => {
xValues.push(x);
yValues.push(y);
});
if (closeRings) {
xValues.push(ring[0][0]);
yValues.push(ring[0][1]);
}
xValues.push(NaN);
yValues.push(NaN);
});
return { xValues, yValues };
}
// A seeded random number generator, so the dots land in the same places every time
function createRandom(seed) {
return () => {
seed = (seed * 16807) % 2147483647;
return (seed - 1) / 2147483646;
};
}
// 2. WHERE THE DOTS GO
// An "area" is the land a count belongs to, with its triangles and their running total of area.
function makeArea(counties, count) {
const triangles = counties.flatMap((county) => county.triangles);
const cumulativeAreas = [];
let area = 0;
for (let t = 0; t < triangles.length; t += 3) {
const [a, b, c] = [triangles[t], triangles[t + 1], triangles[t + 2]];
area += Math.abs((b[0] - a[0]) * (c[1] - a[1]) - (c[0] - a[0]) * (b[1] - a[1])) / 2;
cumulativeAreas.push(area);
}
return { triangles, cumulativeAreas, count };
}
// The areas for one animal. By county: each county with a figure is its own area, and a state's withheld counties
// share what is left of the state total. By state: each whole state is one area, to show what coarse data does.
function getDotAreas(states, animal, unit) {
const areas = [];
states.forEach((state) => {
const known = state.counties.filter((county) => county[animal] > 0);
const knownTotal = known.reduce((sum, county) => sum + county[animal], 0);
const stateTotal = state.totals[animal] >= 0 ? state.totals[animal] : knownTotal; // a few state totals are withheld too
if (unit === "state") {
if (stateTotal > 0) areas.push(makeArea(state.counties, stateTotal));
return;
}
known.forEach((county) => areas.push(makeArea([county], county[animal])));
const withheld = state.counties.filter((county) => county[animal] === WITHHELD);
if (withheld.length && stateTotal > knownTotal) areas.push(makeArea(withheld, stateTotal - knownTotal));
});
return areas;
}
// Round(count / dot value) dots per area, each at a random place inside it: pick a triangle with a chance
// in proportion to its area, then a random point inside that triangle, so the dots spread evenly over the area.
function placeDots(areas, headPerDot, random) {
const xValues = [];
const yValues = [];
areas.forEach(({ triangles, cumulativeAreas, count }) => {
const totalArea = cumulativeAreas[cumulativeAreas.length - 1];
const dotCount = Math.round(count / headPerDot); // an area with under half a dot's worth gets none
for (let d = 0; d < dotCount; d++) {
const target = random() * totalArea;
let low = 0;
let high = cumulativeAreas.length - 1;
while (low < high) {
// binary search for the triangle that holds this share of the area
const mid = (low + high) >> 1;
if (cumulativeAreas[mid] < target) low = mid + 1;
else high = mid;
}
const [a, b, c] = [triangles[low * 3], triangles[low * 3 + 1], triangles[low * 3 + 2]];
let u = random();
let v = random();
if (u + v > 1) {
// fold points from the far half of the parallelogram back into the triangle
u = 1 - u;
v = 1 - v;
}
xValues.push(a[0] + u * (b[0] - a[0]) + v * (c[0] - a[0]));
yValues.push(a[1] + u * (b[1] - a[1]) + v * (c[1] - a[1]));
}
});
return { xValues, yValues };
}
// 3. HOVER TOOLTIP: finds the county under the mouse and shows its figures
class CountyTooltipModifier extends CustomChartModifier2D {
counties;
highlight;
tooltip;
hoveredCounty;
constructor(counties, highlight) {
super();
this.counties = counties;
this.highlight = highlight;
this.tooltip = new NativeTextAnnotation({
text: "",
isHidden: true,
textColor: "#FFFFFF",
fontSize: 15,
background: "#0F1A2B",
multiLineAlignment: EMultiLineAlignment.Left,
padding: new Thickness(6, 10, 6, 10),
lineSpacing: 4,
verticalAnchorPoint: EVerticalAnchorPoint.Bottom
});
}
onAttach() {
super.onAttach();
this.parentSurface.annotations.add(this.tooltip);
}
onDetach() {
this.parentSurface?.annotations.remove(this.tooltip);
super.onDetach();
}
// The smallest county that contains the point (a few independent cities sit inside a county).
// A bounding-box test rules most counties out cheaply; for far more areas, use a spatial index.
findCounty(x, y) {
let found;
for (const county of this.counties) {
const { minX, maxX, minY, maxY } = county.bounds;
if (x < minX || x > maxX || y < minY || y > maxY) continue;
if (!county.rings.some((ring) => isPointInRing(x, y, ring))) continue;
if (!found || county.area < found.area) found = county;
}
return found;
}
modifierMouseMove(args) {
super.modifierMouseMove(args);
const point = translateFromCanvasToSeriesViewRect(args.mousePoint, this.parentSurface.seriesViewRect);
const xAxis = this.parentSurface.xAxes.get(0);
const yAxis = this.parentSurface.yAxes.get(0);
const x = point ? xAxis.getCurrentCoordinateCalculator().getDataValue(point.x) : NaN;
const y = point ? yAxis.getCurrentCoordinateCalculator().getDataValue(point.y) : NaN;
const county = point ? this.findCounty(x, y) : undefined;
if (county !== this.hoveredCounty) {
this.hoveredCounty = county;
this.highlight.clear();
if (county) {
const { xValues, yValues } = ringsToLine(county.rings, true);
this.highlight.appendRange(xValues, yValues);
}
}
if (county) {
const describe = (count) =>
count === WITHHELD ? "withheld (D)" : count === NO_FIGURE ? "no separate figure" : count.toLocaleString("en-US");
const nearRightEdge = x > xAxis.visibleRange.min + xAxis.visibleRange.diff * 0.6;
this.tooltip.text = [
`${county.name}, ${county.state}`,
...ANIMALS.map((animal) => `${animal.label}: ${describe(county[animal.key])}`)
].join("\n");
this.tooltip.horizontalAnchorPoint = nearRightEdge ? EHorizontalAnchorPoint.Right : EHorizontalAnchorPoint.Left;
// Offsets are a fraction of the visible range, so the gap from the cursor looks the same at every zoom level
this.tooltip.x1 = x + xAxis.visibleRange.diff * (nearRightEdge ? -0.012 : 0.012);
this.tooltip.y1 = y + yAxis.visibleRange.diff * 0.03;
}
this.tooltip.isHidden = !county;
}
modifierMouseLeave(args) {
super.modifierMouseLeave(args);
this.tooltip.isHidden = true;
this.hoveredCounty = undefined;
this.highlight.clear();
}
}
// 4. THE CHART
// data: counties grouped by state, with cattle and hogs per county and outlines in kilometres
// (Albers equal-area projection), such as getUsLivestockData() at the end of this file
async function dotDensityMap(divElementId, data) {
const { wasmContext, sciChartSurface } = await SciChartSurface.create(divElementId, {
theme: new SciChartJsNavyTheme()
});
// A map needs no axis labels, but the hidden axes still set the drawing area, so zoom and pan work as usual.
// The extra space leaves room for the buttons (top), the legend (right) and the SciChart logo (bottom).
const xAxis = new NumericAxis(wasmContext, { isVisible: false, growBy: new NumberRange(0.02, 0.22) });
const yAxis = new NumericAxis(wasmContext, { isVisible: false, growBy: new NumberRange(0.06, 0.3) });
sciChartSurface.xAxes.add(xAxis);
sciChartSurface.yAxes.add(yAxis);
// Unpack the states and counties: outlines, triangles, bounds and figures
const states = data.states.map(([state, cattleTotal, hogsTotal, names, cattle, hogs, outlines]) => {
const nameList = names.split("|");
const counties = outlines.split(",").map((encodedRings, i) => {
const rings = encodedRings.split(" ").map(decodeOutline);
const xs = rings.flat().map((p) => p[0]);
const ys = rings.flat().map((p) => p[1]);
const county = {
name: nameList[i],
state,
cattle: cattle[i],
hogs: hogs[i],
rings,
triangles: rings.flatMap((ring) => triangulateRing(ring)),
bounds: { minX: Math.min(...xs), maxX: Math.max(...xs), minY: Math.min(...ys), maxY: Math.max(...ys) },
area: 0
};
county.area = (county.bounds.maxX - county.bounds.minX) * (county.bounds.maxY - county.bounds.minY);
return county;
});
return { state, totals: { cattle: cattleTotal, hogs: hogsTotal }, counties };
});
const counties = states.flatMap((state) => state.counties);
// All the dots of both colours are in one scatter series. A palette provider colours each dot by its animal,
// so the two colours can be drawn mixed together rather than one colour on top of the other.
const dotData = new XyDataSeries(wasmContext, { isSorted: false, containsNaN: false });
const dotMarker = new SquarePointMarker(wasmContext, { width: 2, height: 2, strokeThickness: 0 });
let dotAnimals = new Uint8Array(0); // the animal of each dot, by index: 0 = cattle, 1 = hogs
let dotColors = ANIMALS.map((animal) => parseColorToUIntArgb(animal.color));
const paletteProvider = {
strokePaletteMode: EStrokePaletteMode.SOLID,
onAttached: () => {},
onDetached: () => {},
overridePointMarkerArgb: (xValue, yValue, index) => {
const color = dotColors[dotAnimals[index]];
return { stroke: color, fill: color };
}
};
const dotSeries = new XyScatterRenderableSeries(wasmContext, { dataSeries: dotData, pointMarker: dotMarker, paletteProvider });
// State borders and the coast, and the hovered county's outline (filled in by the tooltip modifier)
const stateBorders = new FastLineRenderableSeries(wasmContext, {
dataSeries: new XyDataSeries(wasmContext, {
...ringsToLine(data.stateBorders.split(" ").map(decodeOutline), false),
isSorted: false,
containsNaN: true
}),
stroke: "#5D6F8F",
strokeThickness: 1
});
const highlight = new XyDataSeries(wasmContext, { isSorted: false, containsNaN: true });
sciChartSurface.renderableSeries.add(
stateBorders,
dotSeries,
new FastLineRenderableSeries(wasmContext, { dataSeries: highlight, stroke: "#FFFFFF", strokeThickness: 2 })
);
// Legend: annotations in relative coordinates (0 to 1 across the chart), so it stays put when you zoom
const relative = { xCoordinateMode: ECoordinateMode.Relative, yCoordinateMode: ECoordinateMode.Relative };
const text = (x1, y1, value, fontSize) =>
new NativeTextAnnotation({
...relative,
x1,
y1,
text: value,
textColor: "#FFFFFF",
fontSize,
multiLineAlignment: EMultiLineAlignment.Left,
lineSpacing: 3,
verticalAnchorPoint: EVerticalAnchorPoint.Center
});
const dotValueText = text(0.825, 0.62, "", 16);
const countTexts = ANIMALS.map((animal, i) => text(0.85, 0.7 + i * 0.11, "", 15));
sciChartSurface.annotations.add(
new BoxAnnotation({ ...relative, x1: 0.81, x2: 0.995, y1: 0.56, y2: 0.97, fill: "#0F1A2BDD", strokeThickness: 0 }),
dotValueText,
...ANIMALS.map((animal, i) => {
const y = 0.7 + i * 0.11;
return new BoxAnnotation({ ...relative, x1: 0.825, x2: 0.84, y1: y - 0.012, y2: y + 0.012, fill: animal.color, strokeThickness: 0 });
}),
...countTexts,
text(0.825, 0.92, "2022 Census of Agriculture", 13)
);
// Redraw the dots for the chosen dot value, unit ("county" or "state") and draw order ("mixed" or an animal on top)
const settings = { headPerDot: 10000, unit: "county", onTop: "mixed" };
const areaCache = {};
const update = (changes) => {
Object.assign(settings, changes);
const style = DOT_STYLES.find((s) => s.headPerDot === settings.headPerDot);
const random = createRandom(2022);
const layers = ANIMALS.map((animal, animalIndex) => {
const cacheKey = `${animal.key}-${settings.unit}`;
if (!areaCache[cacheKey]) areaCache[cacheKey] = getDotAreas(states, animal.key, settings.unit);
return { animalIndex, ...placeDots(areaCache[cacheKey], settings.headPerDot, random) };
});
countTexts.forEach((countText, i) => {
countText.text = `${ANIMALS[i].label}\n${layers[i].xValues.length.toLocaleString("en-US")} dots`;
});
// Draw order: the series draws dots in data order, so later dots cover earlier ones
if (settings.onTop === "cattle") layers.reverse(); // hogs first, cattle last (on top)
const order = layers.flatMap(({ animalIndex, xValues }) => xValues.map((x, i) => [animalIndex, i]));
if (settings.onTop === "mixed") {
// shuffle (Fisher-Yates), so neither colour is systematically on top
for (let i = order.length - 1; i > 0; i--) {
const j = Math.floor(random() * (i + 1));
[order[i], order[j]] = [order[j], order[i]];
}
}
const byAnimal = [];
layers.forEach((layer) => (byAnimal[layer.animalIndex] = layer));
const xValues = new Float64Array(order.length);
const yValues = new Float64Array(order.length);
dotAnimals = new Uint8Array(order.length);
order.forEach(([animalIndex, i], n) => {
xValues[n] = byAnimal[animalIndex].xValues[i];
yValues[n] = byAnimal[animalIndex].yValues[i];
dotAnimals[n] = animalIndex;
});
dotColors = ANIMALS.map((animal) => parseColorToUIntArgb(animal.color + style.alpha));
dotMarker.width = style.size;
dotMarker.height = style.size;
dotData.clear();
dotData.appendRange(xValues, yValues);
dotValueText.text = `1 dot = ${settings.headPerDot.toLocaleString("en-US")} head`;
};
update({});
// Keep the map's shape: one kilometre on the x axis must take the same space as one on the y axis
sciChartSurface.preRender.subscribe(() => {
const rect = sciChartSurface.seriesViewRect;
if (!rect || !rect.width || !rect.height) return; // not laid out yet
const { width, height } = rect;
const xRange = xAxis.visibleRange;
const yRange = yAxis.visibleRange;
const kmPerPixel = Math.max(xRange.diff / width, yRange.diff / height);
const xCentre = (xRange.min + xRange.max) / 2;
const yCentre = (yRange.min + yRange.max) / 2;
const newX = new NumberRange(xCentre - (kmPerPixel * width) / 2, xCentre + (kmPerPixel * width) / 2);
const newY = new NumberRange(yCentre - (kmPerPixel * height) / 2, yCentre + (kmPerPixel * height) / 2);
if (Math.abs(newX.diff - xRange.diff) > 1e-6) xAxis.visibleRange = newX;
if (Math.abs(newY.diff - yRange.diff) > 1e-6) yAxis.visibleRange = newY;
});
sciChartSurface.chartModifiers.add(
new CountyTooltipModifier(counties, highlight),
new MouseWheelZoomModifier(),
new ZoomPanModifier(),
new ZoomExtentsModifier()
);
return { sciChartSurface, update };
}
import { SciChartReact } from "scichart-react";
// dotDensityMap from the JavaScript tab, saved as dotDensityMap.ts
import { dotDensityMap } from "./dotDensityMap";
// initChart builds the chart; SciChartReact creates it, sizes it and cleans it up.
// getYourCountyData() returns your areas in the format of getUsLivestockData() in the JavaScript tab
const initChart = (rootElement: string | HTMLDivElement) => dotDensityMap(rootElement, getYourCountyData());
export const DotDensityMap = () => <SciChartReact initChart={initChart} style={{ width: "100%", height: 560 }} />;
import { Component } from "@angular/core";
import { ScichartAngularComponent } from "scichart-angular";
// dotDensityMap from the JavaScript tab, saved as dotDensityMap.ts
import { dotDensityMap } from "./dotDensityMap";
@Component({
selector: "app-dot-density-map",
standalone: true,
imports: [ScichartAngularComponent],
template: `<scichart-angular [initChart]="initChart" style="display: block; width: 100%; height: 560px"></scichart-angular>`
})
export class DotDensityMapComponent {
// initChart builds the chart; scichart-angular creates it, sizes it and cleans it up.
// getYourCountyData() returns your areas in the format of getUsLivestockData() in the JavaScript tab
initChart = (rootElement: string | HTMLDivElement) => dotDensityMap(rootElement, getYourCountyData());
}
Key points:
- Every dot of both colours is in one XyScatterRenderableSeries with a small
SquarePointMarker. A palette provider (overridePointMarkerArgb) colours each dot by its animal, so the two colours can be shuffled together. placeDotsgives each area its count divided by the dot value, rounded. Outlines are first cut into triangles (triangulateRing); each dot chooses a triangle with a chance in proportion to its size, then a random spot within it. The random numbers are seeded, so every reload draws the same map.getDotAreasdecides where the dots may go: each county, a state's withheld counties together, or each whole state. Changing a setting refills the same data series.- The state borders are one FastLineRenderableSeries with NaN gaps between them. Hover is a custom modifier (
CountyTooltipModifier, based onCustomChartModifier2D) that runs a point-in-polygon test. ApreRenderhandler gives both axes the same kilometres per pixel, so the map never stretches.
See it in the demo app: JavaScript choropleth map · React choropleth map · Angular choropleth map, and a React scatter chart.
Go deeper: SciChart.js scatter chart documentation and SciChart.js choropleth map documentation.
Frequently asked questions
What does a dot density map show?
A dot density map shows how a count is spread over a region: where the things counted are crowded together, where they are thin on the ground, and roughly how many there are. Each dot stands for a fixed number, such as 10,000 cattle, so the number of dots in an area gives its total and how closely they are packed gives its density. It does not show exact locations, because each dot is placed somewhere inside its area, usually at random.
What is an example of a dot density map?
A map of US livestock with one orange dot for every 10,000 cattle and one blue dot for every 10,000 hogs, placed inside each county, is a dot density map. It shows hogs packed into Iowa, southern Minnesota and eastern North Carolina, and cattle spread across the Great Plains, Texas and California's Central Valley. Other common examples are maps of population, farms, votes and crop acreage, each with one dot per fixed number.
Should I use a dot density map or a proportional symbol map?
Use a dot density map when the things you count are spread across each area, such as people, animals or farms, and you want to show the pattern and how dense it is. Use a proportional symbol map, with one circle sized by the total, when the count belongs at a point, such as a city's population, or when readers need to compare the totals of areas. Nobody counts a crowd of dots, so a sized symbol is the better way to show a total.
Who made the first dot density map?
The first dot density map is usually credited to Armand Joseph Frère de Montizon, whose 1830 map of the population of France placed one dot for every 10,000 people* inside each département. His method went almost unnoticed at the time, and other mapmakers took up dot maps independently later in the 19th century.
* This dot value comes from later histories of cartography, including Robinson (1982) in the sources below.How do I make a dot density map in JavaScript?
Join each area's count to its outline, choose a dot value, and work out how many dots each area gets: its count divided by the dot value, rounded. Place that many random points inside each area, for example by cutting the outline into triangles and choosing a triangle in proportion to its area. With SciChart.js, draw all the dots in one XyScatterRenderableSeries, with a palette provider for a colour per category, and the borders with a FastLineRenderableSeries. The same code runs in React or Angular through scichart-react or scichart-angular.
Sources
- USDA National Agricultural Statistics Service, 2022 Census of Agriculture, Volume 1, Chapter 2: County Level Data, tables 11 (cattle and calves) and 12 (hogs and pigs). Public domain; the inventory of each county and state on 31 December 2022, and the US totals. (D) marks a figure withheld to avoid disclosing data for individual farms.
- US Census Bureau, Cartographic Boundary Files, 2020 counties at 1:20,000,000 (
cb_2020_us_county_20m). Public domain; the county outlines and land areas used in the demo and the diagram, re-projected to an equal-area projection and simplified. - Roth, R. E. (2010), Dot density maps. In B. Warf (ed.), Encyclopedia of Geography, SAGE. One-to-one and one-to-many dot maps, mapping counts rather than rates, choosing dot size and dot value together (two or three dots in the smallest areas, dots just merging in the densest), placement guided by other data, and readers' underestimation of totals in dense areas.
- Robinson, A. H. (1982), Early Thematic Mapping in the History of Cartography. University of Chicago Press. The history of early thematic maps, including Frère de Montizon's dot map and how little notice it received.
- Frère de Montizon, A. J. (1830), Carte philosophique figurant la population de la France. Bibliothèque nationale de France, Gallica. The map itself; the online scan wasn't available when this guide was written (November 2026).