From 667eeb24290446ec0d2960c5838655556d0f2331 Mon Sep 17 00:00:00 2001 From: Goutte Date: Wed, 28 Jun 2017 18:07:35 +0200 Subject: [PATCH] Resize the domain of the orbits as well. --- web/static/js/swapp.js | 48 ++++++++++++++++++++++++++++++++++++------------ web/static/js/swapp.ls | 13 +++++++++++-- 2 files changed, 47 insertions(+), 14 deletions(-) diff --git a/web/static/js/swapp.js b/web/static/js/swapp.js index 821d8ff..de9c524 100644 --- a/web/static/js/swapp.js +++ b/web/static/js/swapp.js @@ -243,9 +243,10 @@ } }; SpaceWeather.prototype.resetZoom = function(){ - return timeSeries.forEach(function(ts){ + timeSeries.forEach(function(ts){ return ts.resetZoom(); }); + return this.orbits.resetZoom(); }; return SpaceWeather; }()); @@ -526,7 +527,7 @@ Orbits.prototype.orbitersElements = {}; Orbits.prototype.initOrbiter = function(slug, config, data){ var orbit_ellipse, orbiter, orbit_line, orbit_section, this$ = this; - console.log("Initializing target " + slug + "'s orbit…", config, data); + console.info("Initializing target " + slug + "'s orbit…"); if (slug in this.orbitersElements) { throw new Error("Second init of " + slug); } @@ -557,15 +558,16 @@ }; Orbits.prototype.resize = function(){ var width, height, slug, ref$, config; - width = jQuery(this.container).width() - this.margin.left - this.margin.right; - height = 1.0 * width; + width = Math.ceil($(this.container).width() - this.margin.left - this.margin.right); + height = Math.ceil(1.0 * width); + console.debug("Resizing orbits : " + width + " × " + height + "…"); this.xScale.range([0, width]); this.yScale.range([height, 0]); this.svg.attr('width', width + this.margin.right + this.margin.left).attr('height', height + this.margin.top + this.margin.bottom); this.sun.attr("x", width / 2 - 16).attr("y", height / 2 - 16); for (slug in ref$ = this.orbiters) { config = ref$[slug]; - this.resizeOrbiter(slug, config); + this.resizeOrbiter(slug, config, width, height); } this.xAxis.scale(this.xScale); this.yAxis.scale(this.yScale); @@ -575,11 +577,9 @@ this.yAxisTitle.attr("x", -1 * height / 2).attr("y", -30); return this; }; - Orbits.prototype.resizeOrbiter = function(slug, config){ - var width, height, el, a, b, c, cx, cy, data; - width = Math.floor(jQuery(this.container).width() - this.margin.left - this.margin.right); - height = Math.floor(1.0 * width); - console.debug("Resizing orbiter of " + slug + " to " + width + " × " + height + "…"); + Orbits.prototype.resizeOrbiter = function(slug, config, width, height){ + var el, a, b, c, cx, cy, data; + console.debug("Resizing orbit of " + slug + "…"); el = this.orbitersElements[slug]; el['orbit_section'].attr('d', el['orbit_line']); a = config['orbit']['a']; @@ -610,7 +610,7 @@ Orbits.prototype.moveToDate = function(t){ var slug, ref$, el, data, i, d0, d1, d; if (!t) { - console.log("Trying to move to an undefined date"); + console.warn("Trying to move to an undefined date !"); } for (slug in ref$ = this.orbitersElements) { el = ref$[slug]; @@ -626,7 +626,31 @@ } return this; }; - Orbits.prototype.resizeDomain = function(started_at, stopped_at){}; + Orbits.prototype.resizeDomain = function(started_at, stopped_at){ + var slug, ref$, config, el, data, results$ = []; + for (slug in ref$ = this.orbiters) { + config = ref$[slug]; + el = this.orbitersElements[slug]; + data = this.data[slug].filter(fn$); + el['orbit_section'].datum(data); + results$.push(el['orbit_section'].attr('d', el['orbit_line'])); + } + return results$; + function fn$(d){ + var ref$; + return started_at <= (ref$ = d.t) && ref$ <= stopped_at; + } + }; + Orbits.prototype.resetZoom = function(){ + var slug, ref$, config, el, results$ = []; + for (slug in ref$ = this.orbiters) { + config = ref$[slug]; + el = this.orbitersElements[slug]; + el['orbit_section'].datum(this.data[slug]); + results$.push(el['orbit_section'].attr('d', el['orbit_line'])); + } + return results$; + }; return Orbits; }()); function bind$(obj, key, target){ diff --git a/web/static/js/swapp.ls b/web/static/js/swapp.ls index a85adf9..b851acf 100644 --- a/web/static/js/swapp.ls +++ b/web/static/js/swapp.ls @@ -201,6 +201,7 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE resetZoom: -> timeSeries.forEach((ts) -> ts.resetZoom()) + @orbits.resetZoom() @@ -668,7 +669,15 @@ export class Orbits this resizeDomain: (started_at, stopped_at) -> - # fixme - + for slug, config of @orbiters + el = @orbitersElements[slug] + data = @data[slug].filter (d) -> started_at <= d.t <= stopped_at + el['orbit_section'].datum(data) + el['orbit_section'].attr('d', el['orbit_line']) + resetZoom: -> + for slug, config of @orbiters + el = @orbitersElements[slug] + el['orbit_section'].datum(@data[slug]) + el['orbit_section'].attr('d', el['orbit_line']) -- libgit2 0.21.2