Introduction
d3-maps is a set of components and helpers simplifying creating SVG maps with D3.
Works with your favorite framework, batteries included.
Architecture
Core provides framework-agnostic complex logic (you won't see it)
- Context creation, data transformation
- Map layers types and models: features, markers, zoom, etc
- Utilities for custom layers: choropleth, bubble, etc
Adapters implement the core in a simple way (you'll see it)
- Vue and React bindings (Solid and Svelte coming soon)
- Rendering and reactivity integration
- Declarative components and composables
Installation
bash
npm install @d3-maps/vueCDN support
jsDelivrandUNPKGsupport package-root script URLs for@d3-maps/core,@d3-maps/react, and@d3-maps/vue@d3-maps/reactand@d3-maps/vuebrowser bundles already include@d3-maps/core, so you only need the framework runtime plus the adapter script- browser styles are available from the adapter packages at
@d3-maps/react/index.cssand@d3-maps/vue/index.css esm.shandSkypackuse the package ESM entrypoints, so prefer package-root imports therecdnjsis not an npm mirror, so publishing to npm does not make@d3-maps/*available there automatically
Basic usage
- Get data
ts
import '@d3-maps/vue/index.css'
import type { MapData } from '@d3-maps/vue'
const data: MapData = await fetch('/some-topojson.json').then((res) => res.json())- Pass the data to
MapBase
vue
<script setup lang="ts">
import '@d3-maps/vue/index.css'
import { MapBase, MapFeatures, type MapData } from '@d3-maps/vue'
defineProps<{
data: MapData
}>()
</script>
<template>
<MapBase :data="data">
<MapFeatures />
</MapBase>
</template>- Your first map is ready
Next
Learn core concepts to understand how d3-maps works step by step: data, projection, zoom, markers and more.