Skip to content

Commit

Permalink
use zoom in url (closes #21)
Browse files Browse the repository at this point in the history
  • Loading branch information
RouxRC committed Apr 6, 2020
1 parent e3d9726 commit 74d20d9
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions js/corona.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ new Vue({
.join(",") +
(this.refCountry ? "&align=" + this.refCountry : "") +
"&alignTo=" + this.refCase +
(this.oldrecovered ? "&oldrecovered" : "");
(this.oldrecovered ? "&oldrecovered" : "") +
(this.hiddenLeft || this.hiddenRight ? "&zoom=" + this.hiddenLeft + "," + this.hiddenRight : "");
}
},
watch: {
Expand All @@ -160,7 +161,11 @@ new Vue({
}).sort(function(a, b) {
return b.maxValues["total"][cas.id] - a.maxValues["total"][cas.id];
});
if (oldValue) this.refCountry = null;
if (oldValue) {
this.refCountry = null;
this.hiddenLeft = 0;
this.hiddenRight = 0;
}
this.countriesOrder = "cases";
if (!this.countries.filter(function(c) { return c.selected; }).length) {
var startPlaces = (
Expand All @@ -173,8 +178,6 @@ new Vue({
c.selected = !!~startPlaces.indexOf(c.name);
});
}
this.hiddenLeft = 0;
this.hiddenRight = 0;
this.sortCountries();
},
refCase: function() {
Expand Down Expand Up @@ -235,6 +238,8 @@ new Vue({
el = decodeURIComponent(opt).split(/=/);
if (el[0] === "countries" || el[0] === "places")
options.countries = el[1] ? el[1].split(/,/) : [];
else if (el[0] === "zoom")
options.zoom = el[1] ? el[1].split(/,/) : [];
else if (el[0] === "country")
options.scope = el[1];
else if (el[0] === "alignTo")
Expand Down Expand Up @@ -262,6 +267,10 @@ new Vue({
else if (options.multiples)
this.vizChoice = 'multiples';
else this.vizChoice = 'series';
if (options.zoom) {
this.hiddenLeft = +options.zoom[0];
this.hiddenRight = +options.zoom[1];
}
this.cases.forEach(function(c) {
c.selected = !!options[c.id] && !c.disabled;
});
Expand Down Expand Up @@ -973,7 +982,6 @@ new Vue({
});
this.hiddenLeft = i0;
this.hiddenRight = dates.length - 1 - i1;
this.draw();
},
hover: function(d, i) {
var typ = (this.perDay && this.vizChoice !== "series" ? "surface" : "hoverdate");
Expand Down Expand Up @@ -1059,8 +1067,6 @@ new Vue({
this.hiddenRight += Math.floor(gaugeRight * days * direction);
if (this.hiddenLeft < 0) this.hiddenLeft = 0;
if (this.hiddenRight < 0) this.hiddenRight = 0;
this.draw();
this.displayTooltip(d, i, rects);
},
exportData: function() {
var a = document.createElement('a'),
Expand Down

0 comments on commit 74d20d9

Please sign in to comment.