diff --git a/web/static/js/swapp.js b/web/static/js/swapp.js index 513d742..5773dae 100644 --- a/web/static/js/swapp.js +++ b/web/static/js/swapp.js @@ -313,9 +313,6 @@ }); this.time_series.forEach(function(ts){ ts.options['onMouseOver'] = function(){ - this$.time_series.forEach(function(ts2){ - return ts2.showCursor(); - }); return true; }; ts.options['onMouseOut'] = function(){ @@ -732,7 +729,8 @@ i = this.bisectDate(this.data, x0, 1); d0 = this.data[i - 1]; d1 = this.data[i]; - if (!(d1 && d0)) { + if (!d1 || !d0) { + this.hideCursor(); return; } d = x0 - d0.x > d1.x - x0 ? d1 : d0; @@ -749,6 +747,7 @@ this.cursorValueShadow.attr("transform", transform).text(d.y).attr('text-anchor', mirrored ? 'end' : 'start').attr("dx", dx); this.cursorDate.attr("transform", transform).text(this.timeFormat(d.x)).attr('text-anchor', mirrored ? 'end' : 'start').attr("dx", dx); this.cursorDateShadow.attr("transform", transform).text(this.timeFormat(d.x)).attr('text-anchor', mirrored ? 'end' : 'start').attr("dx", dx); + this.showCursor(); return this; }; return TimeSeries; diff --git a/web/static/js/swapp.ls b/web/static/js/swapp.ls index 3164526..121b3db 100644 --- a/web/static/js/swapp.ls +++ b/web/static/js/swapp.ls @@ -260,9 +260,10 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE } )) ) - @time_series.forEach((ts) ~> # returning true may be faster + # Let's override all time series' input handlers to link them together + @time_series.forEach((ts) ~> # returning true may be faster, how to bench? ts.options['onMouseOver'] = ~> - @time_series.forEach((ts2) -> ts2.showCursor()) ; true + true # let's do nothing, we'll show the cursor during moveCursor() ts.options['onMouseOut'] = ~> @time_series.forEach((ts2) -> ts2.hideCursor()) ; true ts.options['onMouseMove'] = (t) ~> @@ -651,7 +652,10 @@ export class TimeSeries i = @bisectDate(@data, x0, 1) d0 = @data[i - 1] d1 = @data[i] - return unless d1 and d0 + if (not d1) or (not d0) + @hideCursor() + return + d = if x0 - d0.x > d1.x - x0 then d1 else d0 xx = @xScale(d.x) yy = @yScale(d.y) @@ -675,6 +679,7 @@ export class TimeSeries @cursorDateShadow.attr("transform", transform).text(@timeFormat(d.x)) .attr('text-anchor', if mirrored then 'end' else 'start') .attr("dx", dx) + @showCursor() this -- libgit2 0.21.2