svelte-plots-basic 3.2.0 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/2d/Heatmap.svelte +7 -4
package/package.json
CHANGED
package/src/2d/Heatmap.svelte
CHANGED
|
@@ -112,16 +112,19 @@
|
|
|
112
112
|
let rw = $derived(transformObjects([1], axes.tX()));
|
|
113
113
|
let rh = $derived(transformObjects([1], axes.tY()));
|
|
114
114
|
|
|
115
|
-
|
|
116
115
|
// mouse click handler
|
|
117
116
|
function handleClick(e) {
|
|
118
117
|
if (!onclick || typeof onclick !== 'function') return;
|
|
118
|
+
|
|
119
119
|
const el = e.target;
|
|
120
120
|
if (el.tagName !== 'rect') return;
|
|
121
|
+
|
|
122
|
+
const pel = el.parentNode.parentNode;
|
|
123
|
+
const pr = pel.getBoundingClientRect();
|
|
121
124
|
const r = el.getBoundingClientRect();
|
|
122
|
-
const x = r.x + r.width
|
|
123
|
-
const y = r.y - r.height
|
|
124
|
-
onclick(Math.round(y / r.height)
|
|
125
|
+
const x = (r.x - pr.x) + r.width * 0.2;
|
|
126
|
+
const y = (r.y - pr.y) + r.height * 0.2;
|
|
127
|
+
onclick(Math.abs(Math.round(y / r.height)), Math.abs(Math.round(x / r.width)))
|
|
125
128
|
e.stopPropagation();
|
|
126
129
|
}
|
|
127
130
|
|