30 | Shows the percentage of open amenities (based on all opening_hours in OSM) for a given time of the week. For more information, check out the Blog entry by ypid. 31 |
32 |30 | Shows the percentage of open amenities (based on all opening_hours in OSM) for a given time of the week. For more information, check out the Blog entry by ypid. 31 |
32 |54 | The purpose of this statistic is to show the data quality and growth over time. For more information, check out the Blog entry by ypid. 55 |
56 |" + $('#tag_selector').val() + "
has not been used in the selected location yet."
124 | + " You can be the first to add one ☺"
125 | + " It might also be the case that there is a problem with getting the data.",
126 | 'warning', { align: "left", delay: 10000, } );
127 | });
128 | if (type === '#boundary_selector' || typeof(type) === 'undefined') {
129 | load_punchcard(stats_csv_source + punchcard_data_file);
130 | }
131 | } /* }}} */
132 |
133 | function timePointer(plot, currentTime, id, content, func_add) { /* {{{ */
134 | if (typeof(func_add) !== 'function') {
135 | var func_add = function() { return true; };
136 | }
137 |
138 | /* https://stackoverflow.com/a/17533126/2239985 */
139 | var id = 'time-pointer-' + id;
140 |
141 | // Get the currente axes
142 | var axes = plot.getAxes();
143 | var xaxis = axes.xaxis;
144 | var yaxis = axes.yaxis;
145 |
146 | var element = plot.getPlaceholder();
147 |
148 | // Find the chart icon element
149 | var pointer = element.find('#' + id);
150 |
151 | // Check that the intended point is inside the visible area
152 | if(func_add(currentTime, id, content) && (currentTime < xaxis.max) && (currentTime > xaxis.min)) {
153 |
154 | if(pointer.length === 0) {
155 | // If it doesn't exist already, create it
156 | element.append('' + content + '');
157 | pointer = element.find('#' + id);
158 | }
159 |
160 | var plotOffset = plot.offset();
161 | var offset = {
162 | top: plotOffset.top - pointer.height() - 5,
163 | left: xaxis.p2c(currentTime) + plotOffset.left // + pointer.outerWidth(false)
164 | };
165 | pointer.offset(offset);
166 | } else {
167 | // If the currently selected area doesn't contain the point, erase the pointer
168 | pointer.remove();
169 | }
170 | } /* }}} */
171 |
172 | function placeTimePointers(plot) { /* {{{ */
173 | timePointer(plot, new Date(2014, 9, 11).getTime(), "issue-28",
174 | 'Server offline',
175 | function(currentTime, id, content){
176 | var boundary = $('#boundary_selector').val();
177 | return boundary === 'planet=earth';
178 | });
179 | timePointer(plot, new Date(2015, 3, 12).getTime(), "issue-2",
180 | 'Fixed issue 2',
181 | function(currentTime, id, content){
182 | var boundary = $('#boundary_selector').val();
183 | var key = $('#tag_selector').val();
184 | return boundary === 'planet=earth' && (key === 'fee' || key === 'lit');
185 | });
186 | timePointer(plot, new Date(2015, 3, 19).getTime(), "OSMWA1517",
187 | 'Wochenaufgabe');
188 | timePointer(plot, new Date(2017, 1, 12).getTime(), "issue-13",
189 | 'Missing data');
190 | timePointer(plot, new Date(2018, 11, 12).getTime(), "issue-16",
191 | 'Missing data');
192 | } /* }}} */
193 |
194 | /* Create and connect drop down menu to change data source boundary {{{ */
195 | $('#boundary_selector').append(new Option('planet=earth (not an official tag)', 'planet=earth'));
196 | $('#boundary_selector').append(new Option("int_name=Deutschland", "int_name♡Deutschland"));
197 | var boundary_to_name_mapping = {
198 | /* https://de.wikipedia.org/wiki/ISO_3166-2:DE */
199 | 'ISO3166-2=DE-BW': 'DE: Baden-Württemberg',
200 | 'ISO3166-2=DE-BY': 'DE: Bayern',
201 | 'ISO3166-2=DE-BE': 'DE: Berlin',
202 | 'ISO3166-2=DE-BB': 'DE: Brandenburg',
203 | 'ISO3166-2=DE-HB': 'DE: Bremen',
204 | 'ISO3166-2=DE-HH': 'DE: Hamburg',
205 | 'ISO3166-2=DE-HE': 'DE: Hessen',
206 | 'ISO3166-2=DE-MV': 'DE: Mecklenburg-Vorpommern',
207 | 'ISO3166-2=DE-NI': 'DE: Niedersachsen',
208 | 'ISO3166-2=DE-NW': 'DE: Nordrhein-Westfalen',
209 | 'ISO3166-2=DE-RP': 'DE: Rheinland-Pfalz',
210 | 'ISO3166-2=DE-SL': 'DE: Saarland',
211 | 'ISO3166-2=DE-SN': 'DE: Sachsen',
212 | 'ISO3166-2=DE-ST': 'DE: Sachsen-Anhalt',
213 | 'ISO3166-2=DE-SH': 'DE: Schleswig-Holstein',
214 | 'ISO3166-2=DE-TH': 'DE: Thüringen',
215 | };
216 | $.ajax({
217 | type: "GET",
218 | url: stats_csv_source + 'stats_for_boundaries.txt',
219 | dataType: "text",
220 | // contentType: "text/plain; charset=UTF-8",
221 | success: function(data) {
222 | data.split('\n').forEach(function (boundary_selector) {
223 | if (boundary_selector.match(/^[^#]/)) {
224 | boundary_selector = boundary_selector.replace(/♡/g, '=');
225 | var name = boundary_selector;
226 | if (boundary_selector in boundary_to_name_mapping) {
227 | var name = boundary_to_name_mapping[boundary_selector];
228 | }
229 | // if (boundary_selector === 'int_name♡Österreich') {
230 | // console.log(boundary_selector);
231 | // }
232 | $('#boundary_selector').append(new Option(name, boundary_selector));
233 | }
234 | });
235 | },
236 | });
237 | $('#boundary_selector').on('change', function() {
238 | showStatsForKey('#boundary_selector');
239 | });
240 | /* }}} */
241 |
242 | /* Create and connect drop down menu to change data source {{{ */
243 | $.each(tag_keys, function(ind, text) {
244 | $('#tag_selector').append(new Option(text, text));
245 | });
246 | $('#tag_selector').on('change', function() {
247 | showStatsForKey('#tag_selector');
248 | })
249 | /* }}} */
250 |
251 | function processData(allText) {
252 | $('#detailed_view').empty();
253 | $('#overview').empty();
254 |
255 | /* Parse the CSV file {{{ */
256 | // https://stackoverflow.com/a/7431565
257 | var allTextLines = allText.split(/\r\n|\n/);
258 | headers = allTextLines[0].split(',');
259 |
260 | var data_total_values = [];
261 | var data_could_be_parsed = [];
262 | var data_could_be_parsed_percent = [];
263 | var data_with_warning = [];
264 | var data_with_warning_percent = [];
265 | var data_with_unpretty = [];
266 | var data_with_unpretty_percent = [];
267 | var last_data = allTextLines[allTextLines.length - 2].split(','); // Empty line
268 | for (var i = 1; i < allTextLines.length; i++) {
269 | var data = allTextLines[i].split(',');
270 | if (data.length === headers.length) {
271 | var time = new Date(data[0]).getTime();
272 | data_total_values.push([ time, data[1]]);
273 | data_could_be_parsed.push([ time, data[3]]);
274 | data_could_be_parsed_percent.push([ time, data[3] / data[1] * 100]);
275 | data_with_warning.push([ time, data[5]]);
276 | data_with_warning_percent.push([ time, data[5] / data[1] * 100]);
277 | data_with_unpretty.push([ time, data[7]]);
278 | data_with_unpretty_percent.push([ time, data[7] / data[1] * 100]);
279 |
280 | var tarr = [];
281 | for (var j = 0; j < headers.length; j++) {
282 | tarr.push(data[j].trim());
283 | }
284 | }
285 | // console.log(JSON.stringify(data_could_be_parsed_percent, null, ' '));
286 | }
287 | /* }}} */
288 |
289 | var datasets = [ /* {{{ */
290 | {
291 | data: data_total_values,
292 | label_short: 'Total number',
293 | label: 'Total number of values',
294 | checked: true, }, {
295 | data: data_could_be_parsed,
296 | label_short: 'Parsed values',
297 | label: 'Number of values which could be parsed',
298 | }, {
299 | data: data_could_be_parsed_percent,
300 | yaxis: 2,
301 | label_short: 'Parsed values in %',
302 | label: 'Number of values which could be parsed in percent',
303 | checked: true,
304 | percent_number: true,
305 | }, {
306 | data: data_with_warning,
307 | label_short: 'Warning values',
308 | label: 'Number of values which returned a warning',
309 | }, {
310 | data: data_with_warning_percent,
311 | yaxis: 2,
312 | label_short: 'Warning values in %',
313 | label: 'Number of values which returned a warning in percent',
314 | percent_number: true,
315 | }, {
316 | data: data_with_unpretty,
317 | label_short: 'Unpretty values',
318 | label: 'Number of values which are not prettified',
319 | }, {
320 | data: data_with_unpretty_percent,
321 | yaxis: 2,
322 | label_short: 'Unpretty values in %',
323 | label: 'Number of values which are not prettified in percent',
324 | percent_number: true,
325 | },
326 | ]; /* }}} */
327 |
328 | /* Set individual color for each column {{{ */
329 | var i = 0;
330 | $.each(datasets, function(key, val) {
331 | val.color = i;
332 | ++i;
333 | });
334 | /* }}} */
335 |
336 | /* Insert check boxes to select data source columns to plot {{{ */
337 | if ($('#choices').text().length === 0) {
338 | $.each(datasets, function(key, val) {
339 | // val.checked = true;
340 | $("#choices").append("