Created
November 15, 2021 07:28
-
-
Save AnupJoseph/b4fc9a3eacc006ea5e5e20bb8f2c56d4 to your computer and use it in GitHub Desktop.
Map with Svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
import { json } from "d3"; | |
import Marks from "./Marks.svelte"; | |
let dataset = []; | |
json( | |
"https://raw.githubusercontent.com/holtzy/D3-graph-gallery/master/DATA/world.geojson" | |
).then((data) => { | |
dataset = data.features; | |
}); | |
const width = 1200, | |
height = 600; | |
</script> | |
<main> | |
<svg {width} {height}> | |
<Marks {dataset} /> | |
</svg> | |
</main> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
import { geoPath, geoNaturalEarth1 } from "d3"; | |
export let dataset = []; | |
import { draw } from "svelte/transition"; | |
import { quadInOut } from "svelte/easing"; | |
const projection = geoNaturalEarth1(); | |
const path = geoPath(projection); | |
</script> | |
{#each dataset as data} | |
<path | |
transition:draw={{ duration: 5000, delay: 0, easing: quadInOut }} | |
d={path(data)} | |
/> | |
{/each} | |
<style> | |
path { | |
fill: none; | |
stroke: darkgreen; | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment