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 | 401 | return [this.started_at, this.stopped_at]; |
402 | 402 | }; |
403 | 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 | 405 | if (stopped_at < started_at) { |
406 | 406 | ref$ = [stopped_at, started_at], started_at = ref$[0], stopped_at = ref$[1]; |
407 | 407 | } |
... | ... | @@ -419,15 +419,32 @@ |
419 | 419 | formatted_stopped_at = stopped_at.format(); |
420 | 420 | if ((this.started_at <= started_at && started_at <= this.stopped_at) && (this.started_at <= stopped_at && stopped_at <= this.stopped_at)) { |
421 | 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 | 449 | this.orbits.resizeDomain(started_at, stopped_at); |
433 | 450 | } else { |
... | ... | @@ -713,10 +730,12 @@ |
713 | 730 | return this.applyZoom(); |
714 | 731 | }; |
715 | 732 | TimeSeries.prototype.applyZoom = function(){ |
716 | - var t; | |
733 | + var duration, t; | |
734 | + duration = 0; | |
717 | 735 | if (this.visible) { |
736 | + duration = 750; | |
718 | 737 | console.debug("Applying zoom to visible " + this + "…"); |
719 | - t = this.svg.transition().duration(750); | |
738 | + t = this.svg.transition().duration(duration); | |
720 | 739 | this.svg.select('.x.axis').transition(t).call(this.xAxis); |
721 | 740 | this.svg.select('.y.axis').transition(t).call(this.yAxis); |
722 | 741 | this.path.transition(t).attr('d', this.line); |
... | ... | @@ -729,7 +748,16 @@ |
729 | 748 | this.predictiveDataPath.attr('d', this.line); |
730 | 749 | } |
731 | 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 | 762 | TimeSeries.prototype.createCatalogLayers = function(){ |
735 | 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 | 324 | console.info "Resizing the temporal domain from #{formatted_started_at} to #{formatted_stopped_at} without fetching new data…" |
325 | 325 | # We first resize the hidden time series and only afterwards we resize |
326 | 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 | 350 | @orbits.resizeDomain started_at, stopped_at |
330 | 351 | else |
331 | 352 | # @is_invalid = false |
... | ... | @@ -639,9 +660,11 @@ export class TimeSeries |
639 | 660 | @applyZoom() |
640 | 661 | |
641 | 662 | applyZoom: -> |
663 | + duration = 0 | |
642 | 664 | if @visible |
665 | + duration = 750 | |
643 | 666 | console.debug("Applying zoom to visible #{@}…") |
644 | - t = @svg.transition().duration(750) | |
667 | + t = @svg.transition().duration(duration) | |
645 | 668 | @svg.select('.x.axis').transition(t).call(@xAxis) |
646 | 669 | @svg.select('.y.axis').transition(t).call(@yAxis) |
647 | 670 | @path.transition(t).attr('d', @line) |
... | ... | @@ -654,6 +677,13 @@ export class TimeSeries |
654 | 677 | @predictiveDataPath.attr('d', @line) |
655 | 678 | @resizeCatalogLayers() |
656 | 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 | 688 | createCatalogLayers: -> |
659 | 689 | @layers_rects = {} |
... | ... | @@ -676,7 +706,7 @@ export class TimeSeries |
676 | 706 | .attr('y', 0) |
677 | 707 | .attr('height', @plotHeight) |
678 | 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 | 710 | #layer_rect.append('svg:title').text("I AM TEXT") |
681 | 711 | layer_rect |
682 | 712 | ... | ... |