-
Notifications
You must be signed in to change notification settings - Fork 33
/
create-boundaries.html
203 lines (179 loc) · 9.49 KB
/
create-boundaries.html
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<!DOCTYPE html>
<html lang="en">
<head>
<title>Hex cartogram boundaries</title>
<link rel="icon" href="https://open-innovations.org/resources/images/logos/oi-square-10.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8" />
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@OpenInnovates">
<meta name="twitter:url" property="og:url" content="https://open-innovations.org/projects/hexmaps/create-boundaries">
<meta name="twitter:title" property="og:title" content="Hex cartogram boundaries">
<meta name="twitter:description" property="og:description" content="Create boundaries for hex maps.">
<meta name="twitter:image" property="og:image" content="https://open-innovations.org/projects/hexmaps/hexmap.png">
<link rel="StyleSheet" href="resources/style.css" type="text/css" />
<script type="text/javascript" src="resources/oi.hexmap.0.8.2.js"></script>
<script type="text/javascript" src="resources/create-boundaries.js"></script>
<script>
var viewer;
OI.ready(function(){
viewer = new OI.HexBoundaries(document.getElementById('viewer'),{}).init();
});
</script>
<style>
/* Header styles */
header { display: flex; flex-direction: columns; }
header h1 { padding: 1rem; display: inline-block; position: relative; font-size: 1.4rem; }
header h1 img { margin-right: 0.25em; float:left; width:1em;height:1em; }
header .navigation { flex-grow: 1; font-size: 1.5rem; text-align: right; }
header .navigation button {
height: 100%;
aspect-ratio: 1/1;
justify-content: space-between;
border: none;
padding: 0;
color: inherit;
position: relative;
}
header .navigation button.on:focus { background: #dfdfdf!important; }
header .navigation button.on svg { fill: black; }
header .navigation button svg { position: absolute; width: 1.25em!important; height:1.25em!important; top: 50%; left: 50%; max-height: 75%; transform: translate3d(-50%,-50%,0); }
#menu { position: relative; }
.menu-panel { min-width: 300px; max-width: 100vw; z-index: 1000; position: absolute; right: 0; top: 0; }
.menu-panel .row { margin-bottom: 1em; text-align: left; }
.menu-panel .row label { display: block; }
.menu-panel .row:last-child { margin-bottom: 0; }
.menu-panel code { background: white; }
.menu-panel form { position: relative; }
.menu-panel input, #options select {
width: 100%;
line-height: 2em;
height: 2em;
min-width: 2em;
font-size: 1em;
border-radius: 4px;
border: 1px solid #999;
}
.menu-panel input[type=checkbox] { width: auto; }
.menu-panel input.required, .menu-panel input[required] { outline: 2px solid red; }
.loader { position: relative; text-align: center; }
.loader svg { width: 5em; margin: auto; }
#hexmap {
margin: auto;
width: 100%;
height: 90vh;
max-width: 100vw;
position: relative;
}
#hexmap .hex-cell { stroke: white; stroke-width: 2; transition: fill 0.3s ease-in, stroke 0.3s ease-in, stroke-width 0.3s ease-in; }
/* Set the on and off styles for the text labels */
#hexmap .hex-label tspan.on { display: none; }
#hexmap .hex-label tspan.off { display: block; }
#hexmap .hex-label tspan.big { font-weight: bold; font-size: 1.2em; }
#hexmap .hover .hex-label tspan.on { display: block; }
#hexmap .hover .hex-label tspan.off { display: none; }
#hexmap svg { margin: auto; display: block; }
#messages { max-height: 6em; overflow-y: auto; }
.message { padding: 0.25em 0.5em; font-size: 1em; }
.info { background: #e7f2fa; color: #2980b9; }
.save { text-align: left; }
.save button { margin-right: 0.25rem; font-size: 1.4rem; }
#option_form label { font-weight: bold; font-family: Poppins; }
#option_form p.hint { margin-bottom: 0.25em; }
ul { list-style: disc; }
ul li {
line-height: 2em;
margin-left: 2em;
}
code { background: #444; color: inherit; }
ol { margin-left: 2em; }
#scale-names { line-height: 1em; display: grid; grid-template-columns: repeat(auto-fit, minmax(8em, 1fr)); grid-gap: 0.25em; }
#scale-names code { display: inline-block; line-height: 1em; }
.scale-preview { width: 100%; height: 1em; display: block; }
#scale {width: 300px;max-width: 90vw; margin: auto; margin-top: 1em; margin-bottom: 2em; }
footer > p:first-child { margin-top: 0; }
footer p { margin-bottom: 1em; }
footer h2 { margin-top: 2em; }
.padded { padding: 1em; }
.hex-cell { fill-opacity: 1; }
.oi-map .hex path { stroke: white!important; }
.highlighted .hex-cell { stroke: black!important; stroke-width: 2px!important; }
.not-highlighted .hex-cell { opacity: 0.3!important; }
.oi-map .overlay, .oi-map .hex .hex-label { pointer-events: none; }
.oi-map .overlay .hex.outline path { stroke: black!important; stroke-width: 2px!important; stroke-dasharray: 5 4; }
.capture .overlay { display: none; }
#viewer { position: relative; }
#boundary-holder { position: absolute; top: 1em; right: 1em;}
textarea { width: 100%; height: 10em; }
</style>
</head>
<body class="b1-bg">
<div id="main" class="b6-bg">
<header class="b1-bg">
<h1><a href="https://open-innovations.org/projects/hexmaps/"><img src="https://open-innovations.org/resources/images/logos/oi-square-10.svg" /></a> Hex cartogram boundaries</h1>
<nav id="navigation" class="navigation" role="menubar">
<button aria-label="Save" aria-controls="saves" id="menu-save" role="menuitem">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-download" viewBox="0 0 16 16">
<path d="M.5 9.9a.5.5 0 0 1 .5.5v2.5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-2.5a.5.5 0 0 1 1 0v2.5a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-2.5a.5.5 0 0 1 .5-.5"/>
<path d="M7.646 11.854a.5.5 0 0 0 .708 0l3-3a.5.5 0 0 0-.708-.708L8.5 10.293V1.5a.5.5 0 0 0-1 0v8.793L5.354 8.146a.5.5 0 1 0-.708.708z"/>
</svg>
</button><button aria-label="Options" aria-controls="options" id="menu-options" role="menuitem">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-gear-fill" viewBox="0 0 16 16">
<path d="M9.405 1.05c-.413-1.4-2.397-1.4-2.81 0l-.1.34a1.464 1.464 0 0 1-2.105.872l-.31-.17c-1.283-.698-2.686.705-1.987 1.987l.169.311c.446.82.023 1.841-.872 2.105l-.34.1c-1.4.413-1.4 2.397 0 2.81l.34.1a1.464 1.464 0 0 1 .872 2.105l-.17.31c-.698 1.283.705 2.686 1.987 1.987l.311-.169a1.464 1.464 0 0 1 2.105.872l.1.34c.413 1.4 2.397 1.4 2.81 0l.1-.34a1.464 1.464 0 0 1 2.105-.872l.31.17c1.283.698 2.686-.705 1.987-1.987l-.169-.311a1.464 1.464 0 0 1 .872-2.105l.34-.1c1.4-.413 1.4-2.397 0-2.81l-.34-.1a1.464 1.464 0 0 1-.872-2.105l.17-.31c.698-1.283-.705-2.686-1.987-1.987l-.311.169a1.464 1.464 0 0 1-2.105-.872zM8 10.93a2.929 2.929 0 1 1 0-5.86 2.929 2.929 0 0 1 0 5.858z"/>
</svg>
</button>
</nav>
</header>
<div id="menu">
<div id="saves" class="b5-bg padded menu-panel">
<h2>Save</h2>
<p>Only the HexJSON format can be reloaded in this tool for further editing.</p>
</div>
<div id="options" class="b5-bg padded menu-panel">
<h2>Options</h2>
<form id="option_form" name="option_form" method="GET" enctype="multipart/form-data" accept-charset="UTF-8" action="#">
<div class="row">
<label for="hexjson" aria-describedby="hexjson-hint">Layout URL</label>
<p id="hexjson-hint" class="hint">A <a href="hexjson.html">HexJSON file</a> with the layout you want to create boundaries for.</p>
<input id="hexjson" type="text" name="hexjson" class="" placeholder="e.g. https://open-innovations.org/projects/hexmaps/maps/uk-constituencies-2023.hexjson" />
</div>
<button id="btnSubmit" type="submit" class="button c10-bg">Update</button>
</form>
</div>
</div>
<div id="messages"></div>
<div id="viewer" class="padded">
<div id="loader"></div>
<div id="hexmap"></div>
<div id="scale"></div>
<div id="boundary-holder" class="row">
<label for="boundaries">Boundaries</label>
<textarea id="boundaries" name="boundaries"></textarea>
</div>
</div>
</div>
<footer class="b1-bg" id="notes">
<div class="holder">
<h2>Notes</h2>
<p>The aim of this tool is to draw boundaries on hex cartogramsto visualise data on a hex cartogram. You must provide a <a href="hexjson.html">HexJSON</a> file. You can start a new <code>boundaries</code> section using:</p>
<pre>
{
"key":{
"type": "name-of-type",
"edges": []
}
}
</pre>
<p>where <code>key</code> is a unique key to group some boundary lines, <code>name-of-type</code> is a string to define the type of line (useful for styling later), and <code>edges</code> is an array of edges. See <a href="https://open-innovations.org/projects/hexmaps/hexjson#boundaries">HexJSON boundaries</a> for more details.</p>
<h2 id="export">Exporting the map</h2>
<p>Use the <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-download" viewBox="0 0 16 16"><path d="M.5 9.9a.5.5 0 0 1 .5.5v2.5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-2.5a.5.5 0 0 1 1 0v2.5a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-2.5a.5.5 0 0 1 .5-.5"></path><path d="M7.646 11.854a.5.5 0 0 0 .708 0l3-3a.5.5 0 0 0-.708-.708L8.5 10.293V1.5a.5.5 0 0 0-1 0v8.793L5.354 8.146a.5.5 0 1 0-.708.708z"></path></svg> menu to export the map as HexJSON.</p>
<hr />
<p>Hex cartogram boundaries © 2024 <a href="https://odileeds.org/">Open Innovations</a>. Released under an MIT license. <a href="https://github.com/odileeds/hexmaps">Source on Github</a>.</p>
</div>
</footer>
<script src="https://open-innovations.org/resources/oi.log.js"></script>
<script>
OI.log.setup({'id':'odileeds','target':['open-innovations.org','odileeds.org','odileeds.github.io']}).add('action=view');
</script>
</body>
</html>