Commit 667eeb24290446ec0d2960c5838655556d0f2331
1 parent
abcf4c94
Exists in
master
and in
2 other branches
Resize the domain of the orbits as well.
Showing
2 changed files
with
47 additions
and
14 deletions
Show diff stats
web/static/js/swapp.js
... | ... | @@ -243,9 +243,10 @@ |
243 | 243 | } |
244 | 244 | }; |
245 | 245 | SpaceWeather.prototype.resetZoom = function(){ |
246 | - return timeSeries.forEach(function(ts){ | |
246 | + timeSeries.forEach(function(ts){ | |
247 | 247 | return ts.resetZoom(); |
248 | 248 | }); |
249 | + return this.orbits.resetZoom(); | |
249 | 250 | }; |
250 | 251 | return SpaceWeather; |
251 | 252 | }()); |
... | ... | @@ -526,7 +527,7 @@ |
526 | 527 | Orbits.prototype.orbitersElements = {}; |
527 | 528 | Orbits.prototype.initOrbiter = function(slug, config, data){ |
528 | 529 | var orbit_ellipse, orbiter, orbit_line, orbit_section, this$ = this; |
529 | - console.log("Initializing target " + slug + "'s orbit…", config, data); | |
530 | + console.info("Initializing target " + slug + "'s orbit…"); | |
530 | 531 | if (slug in this.orbitersElements) { |
531 | 532 | throw new Error("Second init of " + slug); |
532 | 533 | } |
... | ... | @@ -557,15 +558,16 @@ |
557 | 558 | }; |
558 | 559 | Orbits.prototype.resize = function(){ |
559 | 560 | var width, height, slug, ref$, config; |
560 | - width = jQuery(this.container).width() - this.margin.left - this.margin.right; | |
561 | - height = 1.0 * width; | |
561 | + width = Math.ceil($(this.container).width() - this.margin.left - this.margin.right); | |
562 | + height = Math.ceil(1.0 * width); | |
563 | + console.debug("Resizing orbits : " + width + " × " + height + "…"); | |
562 | 564 | this.xScale.range([0, width]); |
563 | 565 | this.yScale.range([height, 0]); |
564 | 566 | this.svg.attr('width', width + this.margin.right + this.margin.left).attr('height', height + this.margin.top + this.margin.bottom); |
565 | 567 | this.sun.attr("x", width / 2 - 16).attr("y", height / 2 - 16); |
566 | 568 | for (slug in ref$ = this.orbiters) { |
567 | 569 | config = ref$[slug]; |
568 | - this.resizeOrbiter(slug, config); | |
570 | + this.resizeOrbiter(slug, config, width, height); | |
569 | 571 | } |
570 | 572 | this.xAxis.scale(this.xScale); |
571 | 573 | this.yAxis.scale(this.yScale); |
... | ... | @@ -575,11 +577,9 @@ |
575 | 577 | this.yAxisTitle.attr("x", -1 * height / 2).attr("y", -30); |
576 | 578 | return this; |
577 | 579 | }; |
578 | - Orbits.prototype.resizeOrbiter = function(slug, config){ | |
579 | - var width, height, el, a, b, c, cx, cy, data; | |
580 | - width = Math.floor(jQuery(this.container).width() - this.margin.left - this.margin.right); | |
581 | - height = Math.floor(1.0 * width); | |
582 | - console.debug("Resizing orbiter of " + slug + " to " + width + " × " + height + "…"); | |
580 | + Orbits.prototype.resizeOrbiter = function(slug, config, width, height){ | |
581 | + var el, a, b, c, cx, cy, data; | |
582 | + console.debug("Resizing orbit of " + slug + "…"); | |
583 | 583 | el = this.orbitersElements[slug]; |
584 | 584 | el['orbit_section'].attr('d', el['orbit_line']); |
585 | 585 | a = config['orbit']['a']; |
... | ... | @@ -610,7 +610,7 @@ |
610 | 610 | Orbits.prototype.moveToDate = function(t){ |
611 | 611 | var slug, ref$, el, data, i, d0, d1, d; |
612 | 612 | if (!t) { |
613 | - console.log("Trying to move to an undefined date"); | |
613 | + console.warn("Trying to move to an undefined date !"); | |
614 | 614 | } |
615 | 615 | for (slug in ref$ = this.orbitersElements) { |
616 | 616 | el = ref$[slug]; |
... | ... | @@ -626,7 +626,31 @@ |
626 | 626 | } |
627 | 627 | return this; |
628 | 628 | }; |
629 | - Orbits.prototype.resizeDomain = function(started_at, stopped_at){}; | |
629 | + Orbits.prototype.resizeDomain = function(started_at, stopped_at){ | |
630 | + var slug, ref$, config, el, data, results$ = []; | |
631 | + for (slug in ref$ = this.orbiters) { | |
632 | + config = ref$[slug]; | |
633 | + el = this.orbitersElements[slug]; | |
634 | + data = this.data[slug].filter(fn$); | |
635 | + el['orbit_section'].datum(data); | |
636 | + results$.push(el['orbit_section'].attr('d', el['orbit_line'])); | |
637 | + } | |
638 | + return results$; | |
639 | + function fn$(d){ | |
640 | + var ref$; | |
641 | + return started_at <= (ref$ = d.t) && ref$ <= stopped_at; | |
642 | + } | |
643 | + }; | |
644 | + Orbits.prototype.resetZoom = function(){ | |
645 | + var slug, ref$, config, el, results$ = []; | |
646 | + for (slug in ref$ = this.orbiters) { | |
647 | + config = ref$[slug]; | |
648 | + el = this.orbitersElements[slug]; | |
649 | + el['orbit_section'].datum(this.data[slug]); | |
650 | + results$.push(el['orbit_section'].attr('d', el['orbit_line'])); | |
651 | + } | |
652 | + return results$; | |
653 | + }; | |
630 | 654 | return Orbits; |
631 | 655 | }()); |
632 | 656 | function bind$(obj, key, target){ | ... | ... |
web/static/js/swapp.ls
... | ... | @@ -201,6 +201,7 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE |
201 | 201 | |
202 | 202 | resetZoom: -> |
203 | 203 | timeSeries.forEach((ts) -> ts.resetZoom()) |
204 | + @orbits.resetZoom() | |
204 | 205 | |
205 | 206 | |
206 | 207 | |
... | ... | @@ -668,7 +669,15 @@ export class Orbits |
668 | 669 | this |
669 | 670 | |
670 | 671 | resizeDomain: (started_at, stopped_at) -> |
671 | - # fixme | |
672 | - | |
672 | + for slug, config of @orbiters | |
673 | + el = @orbitersElements[slug] | |
674 | + data = @data[slug].filter (d) -> started_at <= d.t <= stopped_at | |
675 | + el['orbit_section'].datum(data) | |
676 | + el['orbit_section'].attr('d', el['orbit_line']) | |
673 | 677 | |
678 | + resetZoom: -> | |
679 | + for slug, config of @orbiters | |
680 | + el = @orbitersElements[slug] | |
681 | + el['orbit_section'].datum(@data[slug]) | |
682 | + el['orbit_section'].attr('d', el['orbit_line']) | |
674 | 683 | ... | ... |