layerchart 0.75.0 → 0.75.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.
@@ -374,12 +374,12 @@
374
374
  />
375
375
  {/each}
376
376
 
377
- {#if stackSeries}
377
+ {#if stackSeries && visibleSeries.length > 1}
378
378
  <Tooltip.Separator {...props.tooltip?.separator} />
379
379
 
380
380
  <Tooltip.Item
381
381
  label="total"
382
- value={sum(series, (s) => {
382
+ value={sum(visibleSeries, (s) => {
383
383
  const seriesTooltipData = s.data ? s.data.find((d) => x(d) === x(data)) : data;
384
384
  const valueAccessor = accessor(s.value ?? (s.data ? asAny(y) : s.key));
385
385
 
@@ -171,18 +171,18 @@
171
171
 
172
172
  const referenceNode = (e.target as Element).closest('.layercake-container')!;
173
173
  const point = localPoint(referenceNode, e);
174
- const localX = point?.x ?? 0;
175
- const localY = point?.y ?? 0;
174
+ const pointerX = point?.x ?? 0;
175
+ const pointerY = point?.y ?? 0;
176
176
 
177
177
  if (
178
178
  // @ts-expect-error
179
- e.offsetX < e.currentTarget?.offsetLeft ||
179
+ pointerX < e.currentTarget?.offsetLeft ||
180
180
  // @ts-expect-error
181
- e.offsetX > e.currentTarget?.offsetLeft + e.currentTarget?.offsetWidth ||
181
+ pointerX > e.currentTarget?.offsetLeft + e.currentTarget?.offsetWidth ||
182
182
  // @ts-expect-error
183
- e.offsetY < e.currentTarget?.offsetTop ||
183
+ pointerY < e.currentTarget?.offsetTop ||
184
184
  // @ts-expect-error
185
- e.offsetY > e.currentTarget?.offsetTop + e.currentTarget?.offsetHeight
185
+ pointerY > e.currentTarget?.offsetTop + e.currentTarget?.offsetHeight
186
186
  ) {
187
187
  // Ignore if within padding of chart
188
188
  hideTooltip();
@@ -197,10 +197,10 @@
197
197
  let xValueAtPoint: any;
198
198
  if ($radial) {
199
199
  // Assume radial is always centered
200
- const { radians } = cartesianToPolar(localX - $width / 2, localY - $height / 2);
200
+ const { radians } = cartesianToPolar(pointerX - $width / 2, pointerY - $height / 2);
201
201
  xValueAtPoint = scaleInvert($xScale, radians);
202
202
  } else {
203
- xValueAtPoint = scaleInvert($xScale, localX - $padding.left);
203
+ xValueAtPoint = scaleInvert($xScale, pointerX - $padding.left);
204
204
  }
205
205
 
206
206
  const index = bisectX($flatData, xValueAtPoint, 1);
@@ -212,7 +212,7 @@
212
212
 
213
213
  case 'bisect-y': {
214
214
  // `y` value at pointer coordinate
215
- const yValueAtPoint = scaleInvert($yScale, localY - $padding.top);
215
+ const yValueAtPoint = scaleInvert($yScale, pointerY - $padding.top);
216
216
 
217
217
  const index = bisectY($flatData, yValueAtPoint, 1);
218
218
  const previousValue = $flatData[index - 1];
@@ -223,8 +223,8 @@
223
223
 
224
224
  case 'bisect-band': {
225
225
  // `x` and `y` values at pointer coordinate
226
- const xValueAtPoint = scaleInvert($xScale, localX);
227
- const yValueAtPoint = scaleInvert($yScale, localY);
226
+ const xValueAtPoint = scaleInvert($xScale, pointerX);
227
+ const yValueAtPoint = scaleInvert($yScale, pointerY);
228
228
 
229
229
  if (isScaleBand($xScale)) {
230
230
  // Find point closest to pointer within the x band
@@ -251,7 +251,7 @@
251
251
  }
252
252
 
253
253
  case 'quadtree': {
254
- tooltipData = quadtree.find(localX, localY, radius);
254
+ tooltipData = quadtree.find(pointerX, pointerY, radius);
255
255
  break;
256
256
  }
257
257
  }
@@ -264,8 +264,8 @@
264
264
 
265
265
  $tooltip = {
266
266
  ...$tooltip,
267
- x: localX,
268
- y: localY,
267
+ x: pointerX,
268
+ y: pointerY,
269
269
  data: tooltipData,
270
270
  };
271
271
  } else {
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "author": "Sean Lynch <techniq35@gmail.com>",
5
5
  "license": "MIT",
6
6
  "repository": "techniq/layerchart",
7
- "version": "0.75.0",
7
+ "version": "0.75.1",
8
8
  "devDependencies": {
9
9
  "@changesets/cli": "^2.27.10",
10
10
  "@mdi/js": "^7.4.47",