-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathjoyplot_random.html
More file actions
77 lines (73 loc) · 2.71 KB
/
joyplot_random.html
File metadata and controls
77 lines (73 loc) · 2.71 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Gridviz joyplot example</title>
<style>
html,
body {
height: 100%; /* Ensure the parent elements have a height so that the map can take up 100% correctly */
margin: 0; /* Remove default margins to prevent scrolling */
overflow: hidden; /* Prevent potential scrollbars */
}
</style>
</head>
<body>
<div id="map" style="height: 100%; width: 100%"></div>
<script src="../../dist/gridviz.js"></script>
<script>
//define map with initial view
const map = new gridviz.Map(document.getElementById('map'), {
x: 4000000,
y: 2960000,
z: 1000,
backgroundColor: 'black',
}).addZoomButtons()
//define multi resolution dataset
const dataset = new gridviz.MultiResolutionDataset(
[1000, 2000, 5000, 10000, 20000, 50000, 100000],
(resolution) =>
new gridviz.TiledGrid(
map,
'https://raw.githubusercontent.com/jgaffuri/tiledgrids/main/data/europe/population2/' +
resolution +
'm/'
)
)
//define style
const style = new gridviz.JoyPlotStyle({
height: (c, r, z, scale) => scale(c.TOT_P_2021),
viewScale: gridviz.viewScale({
valueFunction: (c) => +c.TOT_P_2021,
maxSizeFactor: 5,
stretching: gridviz.powerScale(0.5),
}),
lineColor: () =>
'rgb(' +
255 * Math.random() +
',' +
255 * Math.random() +
',' +
255 * Math.random() +
')',
lineWidth: (y, ys, r, z) => 0.15 * r,
fillColor: () =>
'rgba(' +
255 * Math.random() +
',' +
255 * Math.random() +
',' +
255 * Math.random() +
',0.8)',
})
//add layer to map
map.layers = [
new gridviz.GridLayer(dataset, [style], {
// minPixelsPerCell: 12,
cellInfoHTML: (c) => '<b>' + c.TOT_P_2021 + '</b> inhabitant(s)',
}),
]
</script>
</body>
</html>