Commit b4abddb75e4b70fdd3b1c5c719f8b092ab23c18a

Authored by Goutte
1 parent 391d581c

Fix a small issue with the time series' cursors that has been bugging me for too long.

Showing 2 changed files with 11 additions and 7 deletions   Show diff stats
web/static/js/swapp.js
@@ -313,9 +313,6 @@ @@ -313,9 +313,6 @@
313 }); 313 });
314 this.time_series.forEach(function(ts){ 314 this.time_series.forEach(function(ts){
315 ts.options['onMouseOver'] = function(){ 315 ts.options['onMouseOver'] = function(){
316 - this$.time_series.forEach(function(ts2){  
317 - return ts2.showCursor();  
318 - });  
319 return true; 316 return true;
320 }; 317 };
321 ts.options['onMouseOut'] = function(){ 318 ts.options['onMouseOut'] = function(){
@@ -732,7 +729,8 @@ @@ -732,7 +729,8 @@
732 i = this.bisectDate(this.data, x0, 1); 729 i = this.bisectDate(this.data, x0, 1);
733 d0 = this.data[i - 1]; 730 d0 = this.data[i - 1];
734 d1 = this.data[i]; 731 d1 = this.data[i];
735 - if (!(d1 && d0)) { 732 + if (!d1 || !d0) {
  733 + this.hideCursor();
736 return; 734 return;
737 } 735 }
738 d = x0 - d0.x > d1.x - x0 ? d1 : d0; 736 d = x0 - d0.x > d1.x - x0 ? d1 : d0;
@@ -749,6 +747,7 @@ @@ -749,6 +747,7 @@
749 this.cursorValueShadow.attr("transform", transform).text(d.y).attr('text-anchor', mirrored ? 'end' : 'start').attr("dx", dx); 747 this.cursorValueShadow.attr("transform", transform).text(d.y).attr('text-anchor', mirrored ? 'end' : 'start').attr("dx", dx);
750 this.cursorDate.attr("transform", transform).text(this.timeFormat(d.x)).attr('text-anchor', mirrored ? 'end' : 'start').attr("dx", dx); 748 this.cursorDate.attr("transform", transform).text(this.timeFormat(d.x)).attr('text-anchor', mirrored ? 'end' : 'start').attr("dx", dx);
751 this.cursorDateShadow.attr("transform", transform).text(this.timeFormat(d.x)).attr('text-anchor', mirrored ? 'end' : 'start').attr("dx", dx); 749 this.cursorDateShadow.attr("transform", transform).text(this.timeFormat(d.x)).attr('text-anchor', mirrored ? 'end' : 'start').attr("dx", dx);
  750 + this.showCursor();
752 return this; 751 return this;
753 }; 752 };
754 return TimeSeries; 753 return TimeSeries;
web/static/js/swapp.ls
@@ -260,9 +260,10 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE @@ -260,9 +260,10 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE
260 } 260 }
261 )) 261 ))
262 ) 262 )
263 - @time_series.forEach((ts) ~> # returning true may be faster 263 + # Let's override all time series' input handlers to link them together
  264 + @time_series.forEach((ts) ~> # returning true may be faster, how to bench?
264 ts.options['onMouseOver'] = ~> 265 ts.options['onMouseOver'] = ~>
265 - @time_series.forEach((ts2) -> ts2.showCursor()) ; true 266 + true # let's do nothing, we'll show the cursor during moveCursor()
266 ts.options['onMouseOut'] = ~> 267 ts.options['onMouseOut'] = ~>
267 @time_series.forEach((ts2) -> ts2.hideCursor()) ; true 268 @time_series.forEach((ts2) -> ts2.hideCursor()) ; true
268 ts.options['onMouseMove'] = (t) ~> 269 ts.options['onMouseMove'] = (t) ~>
@@ -651,7 +652,10 @@ export class TimeSeries @@ -651,7 +652,10 @@ export class TimeSeries
651 i = @bisectDate(@data, x0, 1) 652 i = @bisectDate(@data, x0, 1)
652 d0 = @data[i - 1] 653 d0 = @data[i - 1]
653 d1 = @data[i] 654 d1 = @data[i]
654 - return unless d1 and d0 655 + if (not d1) or (not d0)
  656 + @hideCursor()
  657 + return
  658 +
655 d = if x0 - d0.x > d1.x - x0 then d1 else d0 659 d = if x0 - d0.x > d1.x - x0 then d1 else d0
656 xx = @xScale(d.x) 660 xx = @xScale(d.x)
657 yy = @yScale(d.y) 661 yy = @yScale(d.y)
@@ -675,6 +679,7 @@ export class TimeSeries @@ -675,6 +679,7 @@ export class TimeSeries
675 @cursorDateShadow.attr("transform", transform).text(@timeFormat(d.x)) 679 @cursorDateShadow.attr("transform", transform).text(@timeFormat(d.x))
676 .attr('text-anchor', if mirrored then 'end' else 'start') 680 .attr('text-anchor', if mirrored then 'end' else 'start')
677 .attr("dx", dx) 681 .attr("dx", dx)
  682 + @showCursor()
678 683
679 this 684 this
680 685