-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample
80 lines (61 loc) · 1.88 KB
/
sample
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<script lang="ts">
// Country Map Data for CZE @ level1
///////////////////////////////////////////////////////////////////////////////////////////
// IMPORTS
///////////////////////////////////////////////////////////////////////////////////////////
// MAP IMPORTS
import { feature } from 'topojson-client'
import { Chart, Svg, GeoPath, Tooltip, Text } from 'layerchart'
// DATA IMPORTS
import { level1CZE } from '$lib/x04MapJSON/CZE/level1CZE'
///////////////////////////////////////////////////////////////////////////////////////////
// KEY VARIABLES
///////////////////////////////////////////////////////////////////////////////////////////
// ESTABLISH MAP DATA AS FEATURE
const data = feature(level1CZE, level1CZE.objects.data)
</script>
<!-- THE COMPONENT MARKUP-->
<div
class="h-[300px] sm:h-[300px] md:h-[400px] lg:h-[500px] xl:h-[700px] overflow-hidden rounded-md"
>
<Chart
geo={{
fitGeojson: data
}}
padding={{ left: 0, right: 0 }}
tooltip={{ mode: "manual" }}
let:tooltip
>
<Svg>
<g class="data">
{ #each data.features as feature }
<GeoPath
geojson={ feature }
{ tooltip }
class="
fill-primary-100 dark:fill-primary-900
stroke-surface-900 dark:stroke-surface-100
hover:fill-primary-100/30 dark:hover:fill-primary-900/30"
/>
{ /each }
</g>
<g class="labels pointer-events-none">
{ #each data.features as feature }
<GeoPath geojson={ feature } let:geoPath>
{ @const [x, y] = geoPath.centroid(feature) }
<Text
x={ x }
y={ y }
value={ feature.properties.NAME_1 }
textAnchor="middle"
verticalAnchor="middle"
color="gray"
class="xl:block hidden text-[11px] [stroke-width:2px] text-surface-900"
/>
</GeoPath>
{ /each }
</g>
</Svg>
<Tooltip header={(data) => data.properties.NAME_1} let:data />
</Chart>
</div>