We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c2d7c8f commit a1c0b32Copy full SHA for a1c0b32
examples/wasm-demo/www/index.js
@@ -43,10 +43,18 @@ function setupCanvas() {
43
/** Update displayed coordinates. */
44
function onMouseMove(event) {
45
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";
+ var text = "Mouse pointer is out of range";
+
+ if(event.target == canvas) {
+ 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;
58
}
59
60
0 commit comments