Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions src/extras/crosshair.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,22 @@ 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);

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