@@ -72,19 +72,24 @@ Dygraph.Plugins.Crosshair = (function _extras_crosshair_closure() {
7272 ctx . clearRect ( 0 , 0 , width , height ) ;
7373 ctx . strokeStyle = this . strokeStyle_ ;
7474 ctx . beginPath ( ) ;
75-
75+
7676 if ( e . dygraph . selPoints_ . length !== 0 ) {
77- var canvasx = Math . floor ( e . dygraph . selPoints_ [ 0 ] . canvasx ) + 0.5 ; // crisper rendering
78-
79- if ( this . direction_ === "vertical" || this . direction_ === "both" ) {
80- ctx . moveTo ( canvasx , 0 ) ;
81- ctx . lineTo ( canvasx , height ) ;
77+ var p_x = e . dygraph . selPoints_ [ 0 ] ;
78+ if ( p_x . x >= 0 && p_x . x <= 1 ) {
79+ var canvasx = Math . floor ( p_x . canvasx ) + 0.5 ; // crisper rendering
80+
81+ if ( this . direction_ === "vertical" || this . direction_ === "both" ) {
82+ ctx . moveTo ( canvasx , 0 ) ;
83+ ctx . lineTo ( canvasx , height ) ;
84+ }
8285 }
8386 }
8487
8588 if ( this . direction_ === "horizontal" || this . direction_ === "both" ) {
8689 for ( var i = 0 ; i < e . dygraph . selPoints_ . length ; i ++ ) {
87- var canvasy = Math . floor ( e . dygraph . selPoints_ [ i ] . canvasy ) + 0.5 ; // crisper rendering
90+ var p_y = e . dygraph . selPoints_ [ i ] ;
91+ if ( p_y . y < 0 || p_y > 1 ) continue ;
92+ var canvasy = Math . floor ( p_y . canvasy ) + 0.5 ; // crisper rendering
8893 ctx . moveTo ( 0 , canvasy ) ;
8994 ctx . lineTo ( width , canvasy ) ;
9095 }
0 commit comments