Skip to content

Commit

Permalink
Merge commit 'refs/pr/1039'
Browse files Browse the repository at this point in the history
  • Loading branch information
mirabilos committed Jan 11, 2025
2 parents ddcc301 + 7d7955b commit 082cb0e
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/extras/crosshair.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,24 @@ Dygraph.Plugins.Crosshair = (function _extras_crosshair_closure() {
ctx.clearRect(0, 0, width, height);
ctx.strokeStyle = this.strokeStyle_;
ctx.beginPath();

if (e.dygraph.selPoints_.length !== 0) {
var canvasx = Math.floor(e.dygraph.selPoints_[0].canvasx) + 0.5; // crisper rendering

if (this.direction_ === "vertical" || this.direction_ === "both") {
ctx.moveTo(canvasx, 0);
ctx.lineTo(canvasx, height);
var p_x = e.dygraph.selPoints_[0];
if (p_x.x >= 0 && p_x.x <= 1) {
var canvasx = Math.floor(p_x.canvasx) + 0.5; // crisper rendering

if (this.direction_ === "vertical" || this.direction_ === "both") {
ctx.moveTo(canvasx, 0);
ctx.lineTo(canvasx, height);
}
}
}

if (this.direction_ === "horizontal" || this.direction_ === "both") {
for (var i = 0; i < e.dygraph.selPoints_.length; i++) {
var canvasy = Math.floor(e.dygraph.selPoints_[i].canvasy) + 0.5; // crisper rendering
var p_y = e.dygraph.selPoints_[i];
if (p_y.y < 0 || p_y > 1) continue;
var canvasy = Math.floor(p_y.canvasy) + 0.5; // crisper rendering
ctx.moveTo(0, canvasy);
ctx.lineTo(width, canvasy);
}
Expand Down

0 comments on commit 082cb0e

Please sign in to comment.