svelte-plots-basic 3.0.1 → 3.0.2

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.0.1",
4
+ "version": "3.0.2",
5
5
  "author": "Sergey Kucheryavskiy",
6
6
  "license": "MIT",
7
7
  "private": false,
@@ -62,8 +62,8 @@
62
62
  /* handler for mouse events */
63
63
  function handleMouse(e, f) {
64
64
  if (f && e.target.id == "axes-box") {
65
- const x = invTransformCoords([e.offsetX - fontSize * 1.5], tX)[0];
66
- const y = invTransformCoords([e.offsetY], tY)[0];
65
+ const x = invTransformCoords([e.offsetX - left], tX)[0];
66
+ const y = invTransformCoords([e.offsetY - top], tY)[0];
67
67
  f(x, y);
68
68
  }
69
69
  }
@@ -363,8 +363,22 @@
363
363
  -webkit-user-select: none;
364
364
  }
365
365
 
366
+ .series-points1 text,
367
+ .series-points1 tspan {
368
+ dominant-baseline: middle;
369
+ alignment-baseline: middle;
370
+ }
371
+
372
+ .series-points2 text,
373
+ .series-points2 tspan {
374
+ dominant-baseline: central;
375
+ alignment-baseline: central;
376
+ }
377
+
366
378
  .series-text text,
367
379
  .series-text tspan {
380
+ dominant-baseline: middle;
381
+ alignment-baseline: middle;
368
382
  text-anchor: middle;
369
383
  user-select: none;
370
384
  -webkit-user-select: none;
@@ -68,10 +68,8 @@
68
68
  `fill:${faceColor};stroke-width:${lineWidth}px;stroke:${lineColor}; font-size:${markerSize}em;`
69
69
  );
70
70
 
71
- const alignStyleStr = $derived(['◼', '⬥', '+', '✳', '✕'].includes(markerSymbol) ?
72
- `dominant-baseline:central;alignment-baseline:mathematical;` :
73
- `dominant-baseline:middle;alignment-baseline:middle;`
74
- );
71
+ const className = $derived(['◼', '⬥', '+', '✳', '✕'].includes(markerSymbol) ? 'series-points2' : 'series-points1');
72
+
75
73
  // check if all coordinates are correct
76
74
  const isOk = $derived(x && y && x.length === y.length);
77
75
  </script>
@@ -80,7 +78,7 @@
80
78
  <!-- svelte-ignore a11y_click_events_have_key_events -->
81
79
  <!-- svelte-ignore a11y_no_static_element_interactions -->
82
80
  <g onclick={(e) => handleClick(e, 'text', onclick)}
83
- class="series series-points" style={textStyleStr + alignStyleStr} text-anchor="middle">
81
+ class="series series-points {className}" style={textStyleStr} text-anchor="middle">
84
82
  {#each x as v, i}
85
83
  <text x={x[i]} y={y[i]}>{markerSymbol}</text>
86
84
  {/each}