-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathsizeLegend.html
More file actions
39 lines (34 loc) · 1.25 KB
/
sizeLegend.html
File metadata and controls
39 lines (34 loc) · 1.25 KB
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
<div id="map" style="height: 100%; width: 100%"></div>
<script src="../../dist/gridviz.js"></script>
<script src="https://cdn.jsdelivr.net/npm/d3-color@3"></script>
<script src="https://cdn.jsdelivr.net/npm/d3-interpolate@3"></script>
<script src="https://cdn.jsdelivr.net/npm/d3-scale-chromatic@3"></script>
<script src="https://cdn.jsdelivr.net/npm/d3-format@3"></script>
<script>
//define map with initial view
const map = new gridviz.Map(document.getElementById('map'), {
x: 4500000,
y: 2900000,
z: 1000,
}).addZoomButtons()
//define dataset
const dataset = new gridviz.CSVGrid(
map,
'https://raw.githubusercontent.com/eurostat/gridviz/master/assets/csv/Europe/pop_2018_10km.csv',
10000
)
//define style
const style = new gridviz.ShapeColorSizeStyle({
size: (cell) => 20 * Math.sqrt(cell.population),
color: () => 'black',
shape: () => 'circle',
})
//define legends
style.legends = gridviz.sizeLegend([500000, 200000, 10000], (v) => 20 * Math.sqrt(v), {
title: 'Population',
labelFormat: d3.format(',.2r'),
fillColor: 'black',
})
//add layer to map
map.layers = [new gridviz.GridLayer(dataset, [style])]
</script>