@juspay/svelte-ui-components 2.80.4 → 2.80.5
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.
|
@@ -755,7 +755,12 @@
|
|
|
755
755
|
onclick={() => handleClick(bar)}
|
|
756
756
|
/>
|
|
757
757
|
{/if}
|
|
758
|
-
|
|
758
|
+
<!-- Suppress the horizontal value label when its sub-band is thinner
|
|
759
|
+
than the ~11px label, so cramped multi-series charts hide labels
|
|
760
|
+
instead of overlapping them into an unreadable cluster. Consumers
|
|
761
|
+
restore labels by giving the chart more height (aspectRatio /
|
|
762
|
+
scrollable / minBandWidth). -->
|
|
763
|
+
{#if showValues && !isStackedMode && (isVertical || bar.height >= 13)}
|
|
759
764
|
<text
|
|
760
765
|
class="bar-value"
|
|
761
766
|
x={isVertical ? bar.x + bar.width / 2 : bar.x + bar.width + 4}
|
|
@@ -2,10 +2,47 @@
|
|
|
2
2
|
import type { ChartTooltipProperties } from './types';
|
|
3
3
|
|
|
4
4
|
let { data, mouseX = 0, mouseY = 0, customSnippet, classes }: ChartTooltipProperties = $props();
|
|
5
|
+
|
|
6
|
+
const OFFSET = 12;
|
|
7
|
+
|
|
8
|
+
let tooltipEl = $state<HTMLDivElement | null>(null);
|
|
9
|
+
let tooltipWidth = $state(0);
|
|
10
|
+
let tooltipHeight = $state(0);
|
|
11
|
+
|
|
12
|
+
// Clamp against the positioned chart container so the tooltip never spills past
|
|
13
|
+
// (and gets clipped by) an overflow:hidden edge. Re-read on each measure/move.
|
|
14
|
+
const containerWidth = $derived(tooltipEl?.offsetParent?.clientWidth ?? Number.POSITIVE_INFINITY);
|
|
15
|
+
const containerHeight = $derived(
|
|
16
|
+
tooltipEl?.offsetParent?.clientHeight ?? Number.POSITIVE_INFINITY
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
// Horizontal: flip to the left of the cursor when it would overflow the right edge.
|
|
20
|
+
const left = $derived.by(() => {
|
|
21
|
+
let value = mouseX + OFFSET;
|
|
22
|
+
if (value + tooltipWidth > containerWidth) {
|
|
23
|
+
value = mouseX - tooltipWidth - OFFSET;
|
|
24
|
+
}
|
|
25
|
+
return Math.max(0, value);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Vertical: keep the tooltip within the container's top and bottom edges.
|
|
29
|
+
const top = $derived.by(() => {
|
|
30
|
+
let value = mouseY - OFFSET;
|
|
31
|
+
if (value + tooltipHeight > containerHeight) {
|
|
32
|
+
value = containerHeight - tooltipHeight;
|
|
33
|
+
}
|
|
34
|
+
return Math.max(0, value);
|
|
35
|
+
});
|
|
5
36
|
</script>
|
|
6
37
|
|
|
7
38
|
{#if data !== null}
|
|
8
|
-
<div
|
|
39
|
+
<div
|
|
40
|
+
bind:this={tooltipEl}
|
|
41
|
+
bind:clientWidth={tooltipWidth}
|
|
42
|
+
bind:clientHeight={tooltipHeight}
|
|
43
|
+
class="chart-tooltip {classes ?? ''}"
|
|
44
|
+
style="left: {left}px; top: {top}px;"
|
|
45
|
+
>
|
|
9
46
|
{#if typeof customSnippet === 'function'}
|
|
10
47
|
{@render customSnippet(data)}
|
|
11
48
|
{:else}
|