Verified Commit beb9f181 authored by Martin Raifer's avatar Martin Raifer
Browse files

clean up whitespace

parent fd867ec8
......@@ -2,8 +2,8 @@ function makeCumPlot(geojsonData, cumPlotDiv) {
var x=[];
var studyClass=[];
for (i = 0; i < geojsonData.features.length; i++) {
x[i] = geojsonData.features[i].properties.time
studyClass[i]= geojsonData.features[i].properties.classification
x[i] = geojsonData.features[i].properties.time
studyClass[i]= geojsonData.features[i].properties.classification
};
// count frequency of registrations
var freqObject=[]; // object/dictionary with unique dates and frequencies
......@@ -15,7 +15,7 @@ function makeCumPlot(geojsonData, cumPlotDiv) {
var num = x[i];
freqObject[num] = freqObject[num] ? freqObject[num] + 1 : 1;
}
regDates= Object.keys(freqObject)
freq= Object.values(freqObject);
......@@ -25,7 +25,7 @@ function makeCumPlot(geojsonData, cumPlotDiv) {
for (var i = 0; i < freq.length; i++) {
cumFreq[i] = freq[i] + theSum;
theSum = theSum + freq[i];
}
// --------------------------------
......@@ -75,20 +75,20 @@ function makeCumPlot(geojsonData, cumPlotDiv) {
break;
case "management":
FreqObjTheraStrat[num] = FreqObjTheraStrat[num] > 0 ? FreqObjTheraStrat[num] + 1 : 1;
break;
break;
case "traditional chinese medicine":
FreqObjTradChin[num] = FreqObjTradChin[num] > 0 ? FreqObjTradChin[num] + 1 : 1;
break;
case "understanding":
FreqObjUnderstanding[num] = FreqObjUnderstanding[num] > 0 ? FreqObjUnderstanding[num] + 1 : 1;
break;
default:
FreqObjOther[num] = FreqObjOther[num]>0 ? FreqObjOther[num] + 1 : 1;
}
}
freqDrugs= Object.values(FreqObjDrugs);
freqDiagnosis= Object.values(FreqObjDiagnosis);
freqTheraStrat= Object.values(FreqObjTheraStrat);
......@@ -124,14 +124,14 @@ function makeCumPlot(geojsonData, cumPlotDiv) {
var theSumTradChin = 0;
var theSumUnderstanding = 0;
for (var i = 0; i < freqDrugs.length; i++)
for (var i = 0; i < freqDrugs.length; i++)
{
cumFreqDrugs[i] = freqDrugs[i] + theSumDrugs;
theSumDrugs = theSumDrugs + freqDrugs[i];
// all arrays have same lengths
cumFreqDiagnosis[i] = freqDiagnosis[i] + theSumDiagnosis;
theSumDiagnosis = theSumDiagnosis + freqDiagnosis[i];
cumFreqTheraStrat[i] = freqTheraStrat[i] + theSumTheraStrat;
theSumTheraStrat = theSumTheraStrat + freqTheraStrat[i];
......@@ -152,15 +152,15 @@ function makeCumPlot(geojsonData, cumPlotDiv) {
cumFreqOther[i] = freqOther[i] + theSumOther;
theSumOther = theSumOther + freqOther[i];
}
// console.log(cumFreqATMP);
// console.log(cumFreqVaccines);
// console.log(cumFreqTradChin);
// console.log(cumFreqTradChin);
// console.log(cumFreqImpHelpers);
//----------------------------------------
//plotting
......@@ -178,9 +178,9 @@ function makeCumPlot(geojsonData, cumPlotDiv) {
y: cumFreqDiagnosis,
stackgroup: 'one',
name: 'Diagnosis',
line:
line:
{
color: '#1B9E77'
color: '#1B9E77'
},
type: 'scatter'
};
......@@ -190,10 +190,10 @@ function makeCumPlot(geojsonData, cumPlotDiv) {
y: cumFreqUnderstanding,
stackgroup: 'one',
type: 'scatter',
line:
{
line:
{
color: '#BF5B17'
},
},
name: 'Disease understanding'
};
......@@ -202,10 +202,10 @@ function makeCumPlot(geojsonData, cumPlotDiv) {
y: cumFreqTheraStrat,
stackgroup: 'one',
type: 'scatter',
line:
{
line:
{
color: '#386CB0'
},
},
name: 'Therapeutic strategies'
};
......@@ -214,10 +214,10 @@ function makeCumPlot(geojsonData, cumPlotDiv) {
y: cumFreqDrugs,
stackgroup: 'one',
type: 'scatter',
line:
{
line:
{
color: '#7FC97F'
},
},
name: 'Drugs'
};
......@@ -226,9 +226,9 @@ function makeCumPlot(geojsonData, cumPlotDiv) {
y: cumFreqATMP,
stackgroup: 'one',
name: 'Advanced therapy medicinal products',
line:
line:
{
color: '#FDC086'
color: '#FDC086'
},
type: 'scatter'
};
......@@ -238,9 +238,9 @@ function makeCumPlot(geojsonData, cumPlotDiv) {
y: cumFreqVaccines,
stackgroup: 'one',
name: 'Vaccines',
line:
line:
{
color: '#BEAED4'
color: '#BEAED4'
},
type: 'scatter'
};
......@@ -250,9 +250,9 @@ function makeCumPlot(geojsonData, cumPlotDiv) {
y: cumFreqTradChin,
stackgroup: 'one',
name: 'Traditional Chinese medicine',
line:
line:
{
color: '#F0027F'
color: '#F0027F'
},
type: 'scatter'
};
......@@ -262,9 +262,9 @@ function makeCumPlot(geojsonData, cumPlotDiv) {
y: cumFreqImpHelpers,
stackgroup: 'one',
name: 'Impacts on helpers',
line:
line:
{
color: '#FFFF99'
color: '#FFFF99'
},
type: 'scatter'
};
......@@ -276,7 +276,7 @@ function makeCumPlot(geojsonData, cumPlotDiv) {
name: 'Other',
line: {
color: '#666666'
},
},
type: 'scatter'
};
......
......@@ -171,4 +171,4 @@ window.addEventListener('resize', function () {
},{"./components/navigation.js":1}]},{},[2])
//# sourceMappingURL=index.js.map
\ No newline at end of file
//# sourceMappingURL=index.js.map
......@@ -2,7 +2,7 @@ function makePlot(geojsonData, plotDiv) {
var x = [];
for (i = 0; i < geojsonData.features.length; i++) {
x[i] = geojsonData.features[i].properties.time
}
var trace = {
......@@ -51,4 +51,3 @@ function makePlot(geojsonData, plotDiv) {
Plotly.newPlot(plotDiv, data, layout, /*{displayModeBar: false}*/);
};
......@@ -48,7 +48,7 @@ L.TimeDimension.Layer.GeoJsonByType = L.TimeDimension.Layer.GeoJson.extend({
if (this._currentLayer) {
this._map.removeLayer(this._currentLayer);
}
if (layer.getLayers().length) {
if (layer.getLayers().length) {
layer.addTo(this._map);
this._currentLayer = layer;
}
......
......@@ -7,9 +7,9 @@ class TrialsMap {
/**
* Constructor of TrialsMap that set the class properties,
* set the taxonomies colors and init that leaflet map
* @param {*} mapEl
* @param {*} trialsEl
* @param {*} options
* @param {*} mapEl
* @param {*} trialsEl
* @param {*} options
*/
constructor(mapEl, trialsEl, options= {}) {
this.trialsEl = trialsEl
......@@ -22,13 +22,13 @@ class TrialsMap {
this.projectCentroidsUrl = 'assets/data/covid-19-trials.geojson'
this.logoSrc = 'assets/img/logos/heigit_logo.png'
this.tileServiceUrl = 'https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png'
this.mapAttribution = 'Map tiles by <a href="https://carto.com/">Carto</a>, under <a href="https://creativecommons.org/licenses/by/3.0/">CC BY 3.0.</a> Data by <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>, under ODbL.'
this.mapAttribution = 'Map tiles by <a href="https://carto.com/">Carto</a>, under <a href="https://creativecommons.org/licenses/by/3.0/">CC BY 3.0.</a> Data by <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>, under ODbL.'
this.studyCategoryColors = []
this.studyTypeColors = []
// Set study taxonomies (type and categories) colors
this.setTaxonomiesColors()
this.setTaxonomiesColors()
this.initMap()
}
......@@ -69,18 +69,18 @@ class TrialsMap {
maxZoom: 12,
center: [0.0, 0.0],
timeDimension: true,
timeDimensionOptions: {
timeInterval: "2020-01-20/".concat(currentDate),
period: "P1D" },
timeDimensionControl: false,
timeDimensionControlOptions: { position: "topright"}
timeDimensionOptions: {
timeInterval: "2020-01-20/".concat(currentDate),
period: "P1D" },
timeDimensionControl: false,
timeDimensionControlOptions: { position: "topright"}
}
return mapOptions
}
/**
* Set the type and categories study colors
* by creating the studyCategoryColors and
* by creating the studyCategoryColors and
* studyTypeColors props
*/
setTaxonomiesColors = () => {
......@@ -103,7 +103,7 @@ class TrialsMap {
/**
* Set map layers (legends, scale and logo)
* if the layers already exist, remove them
* if the layers already exist, remove them
* and add again, refreshing the data
*/
setMapOverlayers = () => {
......@@ -158,17 +158,17 @@ class TrialsMap {
var typesFragment = L.DomUtil.create('div', 'info legend')
typesFragment.innerHTML += 'Study types (click to hide/show)<br><br>'
let fragment = new DocumentFragment()
for (let type in this.studyTypeColors) {
// Create span element for each category
let spanEl = document.createElement('span')
spanEl.innerText = type.charAt(0).toUpperCase() + type.slice(1)
spanEl.className = 'studyLegend'
spanEl.title = 'Click to hide/show'
// Create i element to be appended to each span
let iEl = document.createElement('i')
iEl.style.background = this.studyTypeColors[type]
iEl.style.background = this.studyTypeColors[type]
// Append i element to the span
spanEl.appendChild(iEl);
......@@ -208,7 +208,7 @@ class TrialsMap {
var categoriesFragment = L.DomUtil.create('div', 'info legend')
categoriesFragment.innerHTML += 'Study categories (click to hide/show)<br><br>'
let fragment = new DocumentFragment();
for (let category in this.studyCategoryColors) {
// Create span element for each category
let spanEl = document.createElement('span')
......@@ -216,11 +216,11 @@ class TrialsMap {
spanEl.className = 'studyLegend'
spanEl.title = 'Click to hide/show'
spanEl.onclick = () => { this.toggleCategoryVisibility(category) }
// Create i element to be appended to each span
let iEl = document.createElement('i')
iEl.style.background = this.studyCategoryColors[category]
iEl.innerText = this.timeDimension_layer && this.timeDimension_layer.disabledTaxonomies.indexOf(category) > -1 ? '' : 'X'
iEl.style.background = this.studyCategoryColors[category]
iEl.innerText = this.timeDimension_layer && this.timeDimension_layer.disabledTaxonomies.indexOf(category) > -1 ? '' : 'X'
// Append i element to the span
spanEl.appendChild(iEl);
......@@ -238,7 +238,7 @@ class TrialsMap {
/**
* Toggle the visibility of a given category
* when run, the function will update the studies loaded
* on the map and also refresh the map overlays
* on the map and also refresh the map overlays
* in order to update the given category overlay status (visible or not)
* @param {String} category
*/
......@@ -266,7 +266,7 @@ class TrialsMap {
if (this.studyTypeColors[type]) {
style.fillColor = this.studyTypeColors[type]
}
return style
return style
}
/**
......@@ -281,7 +281,7 @@ class TrialsMap {
let style = { fillColor: '#666666', color: 'grey', radius: 7, fillOpacity: 0.5, weight: 1, opacity: .7, }
if (this.studyCategoryColors[category]) {
style.fillColor = this.studyCategoryColors[category]
}
}
return style
}
......@@ -292,7 +292,7 @@ class TrialsMap {
addGeojsonLayer = () => {
let that = this
var geojsonData = $.ajax({ url: this.projectCentroidsUrl, dataType: "json" })
// Specify that this code should run once the county data request is complete
$.when(geojsonData).done(function () {
let layer = that.buidGeojsonLayer(geojsonData.responseJSON)
......@@ -323,7 +323,7 @@ class TrialsMap {
* @returns {*} layer
*/
buidGeojsonLayer = (jsonData) => {
let layer
let layer
let that = this
// create geojson layer
if (this.loadByTaxonomy=== "categories") {
......@@ -332,7 +332,7 @@ class TrialsMap {
pointToLayer: function (feature, latlng) {
let marker = L.circleMarker(latlng, {})
marker.on("click", function (data) { that.circleMarkerClick(data, that.map) })
return marker
return marker
},
style: this.getStyleStudyCategory
})
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment