Commit 221bfc4d1227045d8b9422bc24e839e550e97f2c
1 parent
5a7474a9
Exists in
master
and in
2 other branches
Try even more fixes to balance the catalog layer's CPU load.
Showing
2 changed files
with
74 additions
and
16 deletions
Show diff stats
web/static/js/swapp.js
@@ -401,7 +401,7 @@ | @@ -401,7 +401,7 @@ | ||
401 | return [this.started_at, this.stopped_at]; | 401 | return [this.started_at, this.stopped_at]; |
402 | }; | 402 | }; |
403 | SpaceWeather.prototype.resizeDomain = function(started_at, stopped_at){ | 403 | SpaceWeather.prototype.resizeDomain = function(started_at, stopped_at){ |
404 | - var ref$, max_stopped_at, formatted_started_at, formatted_stopped_at; | 404 | + var ref$, max_stopped_at, formatted_started_at, formatted_stopped_at, tsv, tsv_cursor, tsv_length, zoomedOnVisible; |
405 | if (stopped_at < started_at) { | 405 | if (stopped_at < started_at) { |
406 | ref$ = [stopped_at, started_at], started_at = ref$[0], stopped_at = ref$[1]; | 406 | ref$ = [stopped_at, started_at], started_at = ref$[0], stopped_at = ref$[1]; |
407 | } | 407 | } |
@@ -419,15 +419,32 @@ | @@ -419,15 +419,32 @@ | ||
419 | formatted_stopped_at = stopped_at.format(); | 419 | formatted_stopped_at = stopped_at.format(); |
420 | if ((this.started_at <= started_at && started_at <= this.stopped_at) && (this.started_at <= stopped_at && stopped_at <= this.stopped_at)) { | 420 | if ((this.started_at <= started_at && started_at <= this.stopped_at) && (this.started_at <= stopped_at && stopped_at <= this.stopped_at)) { |
421 | console.info("Resizing the temporal domain from " + formatted_started_at + " to " + formatted_stopped_at + " without fetching new data…"); | 421 | console.info("Resizing the temporal domain from " + formatted_started_at + " to " + formatted_stopped_at + " without fetching new data…"); |
422 | - this.time_series.forEach(function(ts){ | ||
423 | - if (!ts.visible) { | ||
424 | - return ts.zoomIn(started_at, stopped_at); | ||
425 | - } | 422 | + tsv = this.time_series.filter(function(ts){ |
423 | + return ts.visible; | ||
426 | }); | 424 | }); |
427 | - this.time_series.forEach(function(ts){ | ||
428 | - if (ts.visible) { | ||
429 | - return ts.zoomIn(started_at, stopped_at); | ||
430 | - } | 425 | + tsv_cursor = 0; |
426 | + tsv_length = tsv.length; | ||
427 | + zoomedOnVisible = new Promise(function(resolve, reject){ | ||
428 | + var tsv_zoom_on_next; | ||
429 | + tsv_zoom_on_next = function(i){ | ||
430 | + var ts; | ||
431 | + if (i >= tsv_length) { | ||
432 | + resolve(); | ||
433 | + return; | ||
434 | + } | ||
435 | + ts = tsv[i]; | ||
436 | + return ts.zoomIn(started_at, stopped_at).then(function(){ | ||
437 | + return tsv_zoom_on_next(i + 1); | ||
438 | + }); | ||
439 | + }; | ||
440 | + return tsv_zoom_on_next(0); | ||
441 | + }); | ||
442 | + zoomedOnVisible.then(function(){ | ||
443 | + return this.time_series.forEach(function(ts){ | ||
444 | + if (!ts.visible) { | ||
445 | + return ts.zoomIn(started_at, stopped_at); | ||
446 | + } | ||
447 | + }); | ||
431 | }); | 448 | }); |
432 | this.orbits.resizeDomain(started_at, stopped_at); | 449 | this.orbits.resizeDomain(started_at, stopped_at); |
433 | } else { | 450 | } else { |
@@ -713,10 +730,12 @@ | @@ -713,10 +730,12 @@ | ||
713 | return this.applyZoom(); | 730 | return this.applyZoom(); |
714 | }; | 731 | }; |
715 | TimeSeries.prototype.applyZoom = function(){ | 732 | TimeSeries.prototype.applyZoom = function(){ |
716 | - var t; | 733 | + var duration, t; |
734 | + duration = 0; | ||
717 | if (this.visible) { | 735 | if (this.visible) { |
736 | + duration = 750; | ||
718 | console.debug("Applying zoom to visible " + this + "…"); | 737 | console.debug("Applying zoom to visible " + this + "…"); |
719 | - t = this.svg.transition().duration(750); | 738 | + t = this.svg.transition().duration(duration); |
720 | this.svg.select('.x.axis').transition(t).call(this.xAxis); | 739 | this.svg.select('.x.axis').transition(t).call(this.xAxis); |
721 | this.svg.select('.y.axis').transition(t).call(this.yAxis); | 740 | this.svg.select('.y.axis').transition(t).call(this.yAxis); |
722 | this.path.transition(t).attr('d', this.line); | 741 | this.path.transition(t).attr('d', this.line); |
@@ -729,7 +748,16 @@ | @@ -729,7 +748,16 @@ | ||
729 | this.predictiveDataPath.attr('d', this.line); | 748 | this.predictiveDataPath.attr('d', this.line); |
730 | } | 749 | } |
731 | this.resizeCatalogLayers(); | 750 | this.resizeCatalogLayers(); |
732 | - return this.hideCursor(); | 751 | + this.hideCursor(); |
752 | + return new Promise(function(resolve, reject){ | ||
753 | + if (0 === duration) { | ||
754 | + return resolve(); | ||
755 | + } else { | ||
756 | + return setTimeout(function(){ | ||
757 | + return resolve(); | ||
758 | + }, duration + 50); | ||
759 | + } | ||
760 | + }); | ||
733 | }; | 761 | }; |
734 | TimeSeries.prototype.createCatalogLayers = function(){ | 762 | TimeSeries.prototype.createCatalogLayers = function(){ |
735 | var catalog_slug, ref$, layers, i$, len$, layer, started_at, stopped_at; | 763 | var catalog_slug, ref$, layers, i$, len$, layer, started_at, stopped_at; |
web/static/js/swapp.ls
@@ -324,8 +324,29 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE | @@ -324,8 +324,29 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE | ||
324 | console.info "Resizing the temporal domain from #{formatted_started_at} to #{formatted_stopped_at} without fetching new data…" | 324 | console.info "Resizing the temporal domain from #{formatted_started_at} to #{formatted_stopped_at} without fetching new data…" |
325 | # We first resize the hidden time series and only afterwards we resize | 325 | # We first resize the hidden time series and only afterwards we resize |
326 | # the visible ones, for a smoother transition. | 326 | # the visible ones, for a smoother transition. |
327 | - @time_series.forEach((ts) -> if not ts.visible then ts.zoomIn(started_at, stopped_at)) | ||
328 | - @time_series.forEach((ts) -> if ts.visible then ts.zoomIn(started_at, stopped_at)) | 327 | + #@time_series.forEach((ts) -> if not ts.visible then ts.zoomIn(started_at, stopped_at)) |
328 | + | ||
329 | + tsv = @time_series.filter((ts) -> ts.visible) | ||
330 | + tsv_cursor = 0 | ||
331 | + tsv_length = tsv.length | ||
332 | + zoomedOnVisible = new Promise((resolve, reject) -> | ||
333 | + | ||
334 | + tsv_zoom_on_next = (i) -> | ||
335 | + if i >= tsv_length | ||
336 | + resolve() | ||
337 | + return | ||
338 | + ts = tsv[i] | ||
339 | + ts.zoomIn(started_at, stopped_at) | ||
340 | + .then(-> tsv_zoom_on_next(i+1)) | ||
341 | + tsv_zoom_on_next(0) | ||
342 | + | ||
343 | + ) | ||
344 | + | ||
345 | + zoomedOnVisible.then(-> | ||
346 | + @time_series.forEach((ts) -> if not ts.visible then ts.zoomIn(started_at, stopped_at)) | ||
347 | + ) | ||
348 | + | ||
349 | +# @time_series.forEach((ts) -> if ts.visible then ts.zoomIn(started_at, stopped_at)) | ||
329 | @orbits.resizeDomain started_at, stopped_at | 350 | @orbits.resizeDomain started_at, stopped_at |
330 | else | 351 | else |
331 | # @is_invalid = false | 352 | # @is_invalid = false |
@@ -639,9 +660,11 @@ export class TimeSeries | @@ -639,9 +660,11 @@ export class TimeSeries | ||
639 | @applyZoom() | 660 | @applyZoom() |
640 | 661 | ||
641 | applyZoom: -> | 662 | applyZoom: -> |
663 | + duration = 0 | ||
642 | if @visible | 664 | if @visible |
665 | + duration = 750 | ||
643 | console.debug("Applying zoom to visible #{@}…") | 666 | console.debug("Applying zoom to visible #{@}…") |
644 | - t = @svg.transition().duration(750) | 667 | + t = @svg.transition().duration(duration) |
645 | @svg.select('.x.axis').transition(t).call(@xAxis) | 668 | @svg.select('.x.axis').transition(t).call(@xAxis) |
646 | @svg.select('.y.axis').transition(t).call(@yAxis) | 669 | @svg.select('.y.axis').transition(t).call(@yAxis) |
647 | @path.transition(t).attr('d', @line) | 670 | @path.transition(t).attr('d', @line) |
@@ -654,6 +677,13 @@ export class TimeSeries | @@ -654,6 +677,13 @@ export class TimeSeries | ||
654 | @predictiveDataPath.attr('d', @line) | 677 | @predictiveDataPath.attr('d', @line) |
655 | @resizeCatalogLayers() | 678 | @resizeCatalogLayers() |
656 | @hideCursor() | 679 | @hideCursor() |
680 | + new Promise((resolve, reject) -> | ||
681 | + if 0 == duration | ||
682 | + resolve() | ||
683 | + else | ||
684 | + setTimeout((-> resolve()), duration+50) | ||
685 | + ) | ||
686 | + | ||
657 | 687 | ||
658 | createCatalogLayers: -> | 688 | createCatalogLayers: -> |
659 | @layers_rects = {} | 689 | @layers_rects = {} |
@@ -676,7 +706,7 @@ export class TimeSeries | @@ -676,7 +706,7 @@ export class TimeSeries | ||
676 | .attr('y', 0) | 706 | .attr('y', 0) |
677 | .attr('height', @plotHeight) | 707 | .attr('height', @plotHeight) |
678 | .attr('fill', '#FFFD64C2') | 708 | .attr('fill', '#FFFD64C2') |
679 | - # Not triggered, mouse events are captured before they reach this rect | 709 | + # ↓ Not triggered, mouse events are captured before they reach this rect |
680 | #layer_rect.append('svg:title').text("I AM TEXT") | 710 | #layer_rect.append('svg:title').text("I AM TEXT") |
681 | layer_rect | 711 | layer_rect |
682 | 712 |