File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -43,10 +43,18 @@ function setupCanvas() {
4343/** Update displayed coordinates. */
4444function onMouseMove ( event ) {
4545 if ( chart ) {
46- const point = chart . coord ( event . offsetX , event . offsetY ) ;
47- coord . innerText = ( point )
48- ? `(${ point . x . toFixed ( 3 ) } , ${ point . y . toFixed ( 3 ) } )`
49- : "Mouse pointer is out of range" ;
46+ var text = "Mouse pointer is out of range" ;
47+
48+ if ( event . target == canvas ) {
49+ let actualRect = canvas . getBoundingClientRect ( ) ;
50+ let logicX = event . offsetX * canvas . width / actualRect . width ;
51+ let logicY = event . offsetY * canvas . height / actualRect . height ;
52+ const point = chart . coord ( logicX , logicY ) ;
53+ text = ( point )
54+ ? `(${ point . x . toFixed ( 3 ) } , ${ point . y . toFixed ( 3 ) } )`
55+ : text ;
56+ }
57+ coord . innerText = text ;
5058 }
5159}
5260
You can’t perform that action at this time.
0 commit comments