Appearance
Charts > Catalonia map
A Catalonia map that visually represents geographical data by mapping it onto a geographic layout, using colors to indicate different values or categories.
The Chart
Download example CSV
Copy HTML
Playground
Style
Color for borders
Min and max color for color scale
Usage Example (with tooltip)
vue
<template>
<CataloniaMap @hover="setTooltip" :data="data" />
<OTTooltip :info="tooltip">
{{ tooltip?.data?.properties?.nom }}
</OTTooltip>
</template>
<script setup>
import useTooltip from "@/functions/useTooltip.js";
const [tooltip, setTooltip] = useTooltip();
</script>Component API
The map is built with d3 and SVG using a TopoJSON file. Store the TopoJSON file insrc/assets/maps, or change the import statements in the component file.
Data
js
{
ESP: 40,
PRT: 35,
FRA: 55,
...
}Props
| Name | Default | Description | Type |
|---|---|---|---|
| data | {} | The dataset with ids as keys | Object |
| strokeColor | white | The color of the borders | String |
| highlightColor | black | The stroke color for the highlighted region | String |
| noDataColor | #eee | The color for regions without data | String |
| adjustSize | true | Whether or not the map should adapt to a set height/width | Boolean |
| maxZoom | 16 | The maximum zoom level | Number |
| zoomScale | 1 | The zoom scale factor | Number |
| color | { min: '#eff3ff', max: '#084594' } | The colors for linear color scale or custom color function | Object | Function |
| selected | null | The id of comarca to zoom in on | String | Number |
Events
| Name | Argument | Description |
|---|---|---|
| @select | { target, data } | Emitted when region is clicked |
| @hover | { target, data } | null | Emitted when region is hovered |
Dependencies
- d3
- topojson-client
- cat_munis.json