layerchart 2.0.0-next.40 → 2.0.0-next.41
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.
|
@@ -192,8 +192,8 @@
|
|
|
192
192
|
const ctx = getChartContext();
|
|
193
193
|
const tooltipCtx = getTooltipContext();
|
|
194
194
|
|
|
195
|
-
let tooltipWidth = $state(
|
|
196
|
-
let tooltipHeight = $state(
|
|
195
|
+
let tooltipWidth = $state<number | null>(null);
|
|
196
|
+
let tooltipHeight = $state<number | null>(null);
|
|
197
197
|
|
|
198
198
|
function alignValue(value: number, align: Align, additionalOffset: number, tooltipSize: number) {
|
|
199
199
|
const alignOffset = align === 'center' ? tooltipSize / 2 : align === 'end' ? tooltipSize : 0;
|
|
@@ -201,12 +201,11 @@
|
|
|
201
201
|
}
|
|
202
202
|
|
|
203
203
|
const positions = $derived.by(() => {
|
|
204
|
-
if
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
const tooltipY = untrack(() => tooltipCtx.y);
|
|
208
|
-
return { x: tooltipX, y: tooltipY };
|
|
204
|
+
// if no data or tooltip size is not known yet, return null
|
|
205
|
+
if (!tooltipCtx.data || tooltipWidth === null || tooltipHeight === null) {
|
|
206
|
+
return { x: null, y: null };
|
|
209
207
|
}
|
|
208
|
+
|
|
210
209
|
const xBandOffset = isScaleBand(ctx.xScale)
|
|
211
210
|
? ctx.xScale.step() / 2 - (ctx.xScale.padding() * ctx.xScale.step()) / 2
|
|
212
211
|
: 0;
|
|
@@ -345,8 +344,8 @@
|
|
|
345
344
|
};
|
|
346
345
|
});
|
|
347
346
|
|
|
348
|
-
const motionX = createMotion(
|
|
349
|
-
const motionY = createMotion(
|
|
347
|
+
const motionX = createMotion(null, () => positions.x, motion);
|
|
348
|
+
const motionY = createMotion(null, () => positions.y, motion);
|
|
350
349
|
|
|
351
350
|
$effect(() => {
|
|
352
351
|
if (!tooltipCtx.data) {
|
|
@@ -63,7 +63,7 @@ function setupTracking(motion, getValue, options) {
|
|
|
63
63
|
if (options.controlled)
|
|
64
64
|
return;
|
|
65
65
|
$effect(() => {
|
|
66
|
-
motion.set(getValue());
|
|
66
|
+
motion.set(getValue(), { instant: motion.target == null });
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
69
|
export function createMotion(initialValue, getValue, motionProp, options = {}) {
|
package/package.json
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
"author": "Sean Lynch <techniq35@gmail.com>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "techniq/layerchart",
|
|
7
|
-
"
|
|
7
|
+
"homepage": "https://layerchart.com",
|
|
8
|
+
"version": "2.0.0-next.41",
|
|
8
9
|
"devDependencies": {
|
|
9
10
|
"@changesets/cli": "^2.29.6",
|
|
10
11
|
"@iconify-json/lucide": "^1.2.62",
|