DocumentationNuxt Charts v3

TopoJSON Map

Interactive geographic maps with region fills, points, and routes, powered by D3.

Show visitors by country, mark office locations, or connect cities with routes. TopoJSONMap includes a world dataset, so your first map needs no geometry import or extra dependencies. Maps inherit the same theme, tooltip, legend, and loading options as other Nuxt Charts components.

Color Countries by Value

Pass country records through data.areas and choose a numeric field with value. The component calculates the color domain from your data. The bundled map matches ISO alpha-2, alpha-3, and numeric country codes.

Use valueDomain to keep the same scale across several maps, colorRange to select the low and high colors, or colorScale to supply your own function. Explicit areaColor overrides automatic coloring; otherwise a row's color takes precedence over its numeric value. Areas without values use --vc-map-feature-color.

Mark Locations

Points use longitude and latitude in degrees. Labels appear in tooltips; showPointLabels also renders them beside the markers. Markers keep their pixel size when the map zooms.

AmsterdamNew YorkTokyo

Point styles accept fixed values or functions. For example, :point-size="point => Math.sqrt(Number(point.orders))" sizes markers by their data. Use mapFitToPoints to focus on the visible points. Set heatmapMode to combine nearby points into a blurred layer; individual markers reappear at heatmapModeZoomLevelThreshold (default 4).

Connect Points

Links reference point IDs or point objects through source and target. The default geodesic follows a great-circle route and clips at the date line and globe edge. Use linkCurve="straight" for a straight projected line or linkCurve="arc" for a curved projected connection.

AmsterdamNew YorkTokyoSydney

Use Your Own Geography

Pass topoJson or geoJson to replace the bundled map. Supported inputs are a TopoJSON Topology, GeoJSON FeatureCollection, Feature, or geometry. Place your data in public/maps/ and load it with useFetch:

<script setup lang="ts">
const { data: topology, status, error } = await useFetch<MapGeometry>('/maps/regions.topo.json')
const data = { areas: [{ id: 'north', value: 42 }] }
</script>

<template>
  <TopoJSONMap
    :topo-json="topology ?? undefined"
    map-feature-key="regions"
    feature-id="region_code"
    :data="data"
    value="value"
    :loading="status === 'pending'"
    :error="error?.message"
  />
</template>

mapFeatureKey selects an object inside topology.objects. When omitted, the component chooses countries, land, or the first object. featureId chooses the feature property matched against area.id; it also accepts a function. The default is feature.id.

Area callbacks, events, and tooltips receive the joined area: feature properties, your row fields, properties, and the original feature. GeoJSON polygon winding is normalized for D3 without changing your input.

Choose a Projection

Use projection="naturalEarth" (default), "mercator", "equalEarth", "equirectangular", "orthographic", or "albersUsa". The projection fits the geometry into the available space on resize.

For a configured projection, install d3-geo in your app and pass its projection or a factory:

<script setup lang="ts">
import { geoOrthographic } from 'd3-geo'
const projection = () => geoOrthographic().rotate([-20, -25])
</script>

<template>
  <TopoJSONMap :projection="projection" show-sphere show-graticule />
</template>

Set :fit-view="false" when your projection already specifies its scale and translation. Factories create an independent projection per component; a passed projection instance is configured in place during fitting. Globe projections hide features and markers on the back face.

Interaction and Custom Rendering

Maps support drag, touch pinch, and double-click zoom. zoomOnScroll enables wheel zoom. Enable showControls for zoom/reset buttons or call the exposed zoomIn(), zoomOut(), zoomTo(scale), and resetView() methods. fitToPoints(points?) and zoomToFeature(id) focus on data. zoomOnClick enables this behavior when a point or region is clicked.

Keyboard users can focus the map and use arrow keys to pan, +/- to zoom, and 0/Home to reset. Regions, points, and routes expose tooltips on focus and activate with Enter or Space. ariaLabel, ariaDescription, and the hidden data table provide accessible descriptions.

<TopoJSONMap :data="data">
  <template #tooltip="{ values, kind }">
    <div class="rounded-lg bg-elevated px-3 py-2 text-sm">
      {{ kind }}: {{ values.label ?? values.name ?? values.id }}
    </div>
  </template>
</TopoJSONMap>

The feature, point, and link slots replace individual SVG marks and receive typed values, x, y, path, color, radius, scale, and projection. The default slot renders SVG overlays in the zoomed group and receives width, height, transform, and projection. The legend slot receives items.

Props

Geometry, Layout, and Areas

PropTypeDefaultPurpose
dataMapData{}Optional areas, points, and links.
topoJson / geoJsonMapGeometryBundled worldCustom geometry. geoJson takes precedence.
mapFeatureKeystringAutoTopoJSON object name.
featureIdstring | (feature) => string | numberFeature IDJoin property/accessor.
height / widthnumber | string400 / '100%'Container dimensions.
projectionName, D3 projection, or factory'naturalEarth'Geographic projection.
fitViewbooleantrueFit projection to geometry.
fitViewPaddingnumber12Fit inset in pixels.
paddingnumber | Partial<ChartPadding>undefinedOverride fit insets.
valueField name or accessorarea.valueNumeric choropleth value.
valueDomain[number, number]Data extentColor scale bounds.
colorRange[string, string]Area fill → primaryLow/high colors.
colorScale(value: number) => stringAutoCustom color mapping.
areaColor, areaStroke, areaCursorstring | (area, index) => stringTheme / theme / pointerArea appearance.
areaStrokeWidthnumber | (area, index) => number0.6Boundary width in pixels.
PropTypeDefaultPurpose
pointColor, pointStrokeColor, pointCursor, pointLabelString or accessorRow/themeMarker appearance and label.
pointSize / pointRadiusNumber or accessorRow radius / 5Pixel radius; pointRadius takes precedence.
pointStrokeWidthNumber or accessor1.5Marker outline width.
showPointLabelsbooleanfalseRender point labels.
linkColor, linkCursor, linkDasharrayString or accessorRow/themeRoute appearance.
linkWidthNumber or accessorRow width / 1.5Route width in pixels.
linkCurve'geodesic' | 'straight' | 'arc''geodesic'Connection shape.
linkCurvaturenumber0.2Arc bend as a fraction of distance.
mapFitToPointsbooleanfalseFocus on visible markers after updates.
heatmapModebooleanfalseBlur the point layer.
heatmapModeBlurStdDeviationnumber12Heatmap blur.
heatmapModeZoomLevelThresholdnumber4Switch to markers at this zoom.
maxDataPointsnumber2000Limit each point/link layer.

Zoom and Shared Chart Options

PropTypeDefaultPurpose
disableZoom, zoomOnScroll, showControls, zoomOnClickbooleanfalseInteraction options.
zoomFactornumber1Initial/reset scale.
zoomExtent[number, number][1, 8]Allowed scale range.
zoomDuration / durationnumber250Programmatic zoom animation; respects reduced motion.
showSphere, showGraticulebooleanfalseGlobe outline and geographic grid.
sphereColor, graticuleColor, backgroundColorstringThemeBackground styling.
categories, legendPosition, legendStyle, legendVariant, hideLegendShared chart optionsBottom centerLegend styling.
hideTooltip, tooltipVariant, tooltipRoundnessShared chart optionsChart defaultsTooltip styling.
tooltipTitleFormatter(datum) => string | numberLabel/name/IDTooltip title.
yFormatter(value: number) => stringNumber formatNumeric tooltip values.
themeChartThemeHost tokensShared per-map theme.
loading, loadingLabel, error, emptyLabelShared chart options—Loading, error, and empty states.
ariaLabel, ariaDescription, accessibleDataTableShared chart optionsTable enabledAccessibility.

Events

feature-click, point-click, and link-click emit (values, event). mouseenter and mouseleave emit (values, event) for pointer hover and keyboard focus. zoom emits { x, y, k }.

Geometry and routes use D3 geographic projections and geographic paths. Interaction uses D3 zoom.