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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "svelte-plots-basic",
3
3
  "description": "Svelte components for creating simple plots",
4
- "version": "3.2.0",
4
+ "version": "3.2.1",
5
5
  "author": "Sergey Kucheryavskiy",
6
6
  "license": "MIT",
7
7
  "private": false,
@@ -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 / 2;
123
- const y = r.y - r.height / 2;
124
- onclick(Math.round(y / r.height) - 1, Math.round(x / r.width) - 1)
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