Repository navigation
Expand file tree
/
Copy pathcircle.js
More file actions
executable file
·86 lines (73 loc) · 2.66 KB
/
Copy pathcircle.js
File metadata and controls
executable file
·86 lines (73 loc) · 2.66 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
78
79
80
81
82
83
84
85
86
"use strict";
// missing forEach on NodeList for IE11
// thanks panthony: https://github.com/miguelcobain/ember-paper/issues/1058
if (window.NodeList && !NodeList.prototype.forEach) {
NodeList.prototype.forEach = Array.prototype.forEach;
}
var geoDataURL = "../zcta.topo.json";
var covidDataURL = "../FakeZCTAData.csv";
var geoObj = {};
var covidObj = {};
var viewObj = {};
var countSpec = "mapCountCircle.vl.json";
var deathCountSpec = "mapDeathCountCircle.vl.json";
var rateSpec = "mapRate.vl.json";
var deathRateSpec = "mapDeathRate.vl.json";
var percentSpec = "mapPercent.vl.json";
var deathSpec = "";
var radios = [];
var opt = {
"renderer": "svg"
};
var el = document.getElementById('#map'); // this code listens to the form with map chooser; must run after DOM loads
window.onload = listenRadios;
function listenRadios() {
radios = document.querySelectorAll('input[type=radio][name="mapRadioGroup"]');
radios.forEach(function (radio) {
return radio.addEventListener('change', function () {
if (radio.value === 'Case Rate') {
rateMapCreate();
} else if (radio.value === 'Case Count') {
countMapCreate();
} else if (radio.value === 'Death Count') {
deathCountMapCreate();
} else if (radio.value === 'Death Rate') {
deathRateMapCreate();
} else {
percentMapCreate();
} // for if chosenField is Percent Positive
;
});
});
} //this function creates the map
function rateMapCreate() {
vegaEmbed('#map', rateSpec, opt).then(function (result) {
// Access the Vega view instance (https://vega.github.io/vega/docs/api/view/) as result.view
viewObj = result.view;
}).catch(console.error);
}
function countMapCreate() {
vegaEmbed('#map', countSpec, opt).then(function (result) {
// Access the Vega view instance (https://vega.github.io/vega/docs/api/view/) as result.view
viewObj = result.view;
}).catch(console.error);
}
function percentMapCreate() {
vegaEmbed('#map', percentSpec, opt).then(function (result) {
// Access the Vega view instance (https://vega.github.io/vega/docs/api/view/) as result.view
viewObj = result.view;
}).catch(console.error);
}
function deathRateMapCreate() {
vegaEmbed('#map', deathRateSpec, opt).then(function (result) {
// Access the Vega view instance (https://vega.github.io/vega/docs/api/view/) as result.view
viewObj = result.view;
}).catch(console.error);
}
function deathCountMapCreate() {
vegaEmbed('#map', deathCountSpec, opt).then(function (result) {
// Access the Vega view instance (https://vega.github.io/vega/docs/api/view/) as result.view
viewObj = result.view;
}).catch(console.error);
}
rateMapCreate();