Skip to content

Commit

Permalink
Merge pull request #1034 from n-gist/crosshair-selPoints-error-fix
Browse files Browse the repository at this point in the history
Crosshair plugin runtime error on moving cursor out fix
  • Loading branch information
mirabilos authored Jan 11, 2025
2 parents 3a5403a + 0b31994 commit 09252ae
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/extras/crosshair.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,14 @@ Dygraph.Plugins.Crosshair = (function _extras_crosshair_closure() {
ctx.clearRect(0, 0, width, height);
ctx.strokeStyle = this.strokeStyle_;
ctx.beginPath();

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);

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);
}
}

if (this.direction_ === "horizontal" || this.direction_ === "both") {
Expand Down

0 comments on commit 09252ae

Please sign in to comment.