Skip to content
On this page

Charts > World map ​

A world map that visually represents geographical data by mapping it onto a geographic layout, using colors to indicate different values or categories.

The Chart ​

: No data
Download example CSV
Copy HTML

Playground ​

Map options

How the curved two-dimensional surface of the globe is represent on a plane.

Style

Min and max color for color scale
Color for borders

Component API ​

The map is built with d3 and SVG using a TopoJSON file. Store the TopoJSON file in src/assets/maps, or change the import statements in the component file.

Usage Example (with tooltip) ​

vue
<template>
  <WorldMap :key="key" :highlighted="highlighted" @hover="setTooltip" />

  <OTTooltip :info="tooltip" :follow-mouse="true">
    {{ tooltip?.data?.id }}:
    {{ tooltip?.data?.value ? tooltip?.data?.value : "No data" }}
  </OTTooltip>
</template>

<script setup>
import useTooltip from "@/functions/useTooltip.js";

const [tooltip, setTooltip] = useTooltip();
</script>

Data ​

js
{
  ESP: 40,
  PRT: 35,
  FRA: 55,
  ...
}

Props ​

NameDefaultDescriptionType
data{}The datasetObject
color{ min: '#eff3ff', max: '#084594' }The colors for linear color scale or custom color functionObject | Function
strokeColorwhiteThe color of the bordersString
highlightColorblackThe stroke color for the highlighted regionString
noDataColor#eeeThe color for regions without dataString
strokeColorNoData#fffThe stroke color for regions without dataString
duration500The time of the color changing animation in msNumber
highlightednullThe id of the highlighted regionString | Number
adjustSizefalseWhether or not the map should adapt to a set height/widthBoolean
removeFeatures['010']The ids of features not to showArray
removeFeaturesForBounds['FJI','USA','TON',...]The ids of features to ignore when calculating map boundsArray
accessor(d) => d.properties.ISO_A3The function to access the id of a featureFunction
fitBoundsToDatafalseWhether or not to limit boundaries of map to regions with dataBoolean
maxZoom16The maximum zoom levelNumber
useBgPatternfalseWhether or not to use a pattern for regions without dataBoolean

Events ​

NameArgumentDescription
@select{ target, data }Emitted when region is clicked
@hover{ target, data } | nullEmitted when region is hovered
@zoom{ k, x, y }Emitted when map is zoomed

Dependencies ​

  • d3
  • topojson-client
  • countries.json