Skip to content

Commit ff86afd

Browse files
committed
always position tooltip above marker
1 parent 500299d commit ff86afd

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

src/lib/components/data-vis/line-chart/ValueLabel.svelte

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,26 @@
1717
let horizontalPadding = $derived(verticalPadding * 2);
1818
</script>
1919

20-
{#if tooltipSnippet === undefined}
21-
<div
22-
style="position:absolute;
20+
<div
21+
style="position:absolute;
2322
top: {markerRect?.y - (textDimensions?.height ?? 0) - 15}px;
2423
left: {markerRect?.x +
25-
(markerRect?.width ?? 0) / 2 -
26-
(textDimensions?.width ?? 0) / 2}px;
24+
(markerRect?.width ?? 0) / 2 -
25+
(textDimensions?.width ?? 0) / 2}px;
2726
pointer-events: none;
28-
background-color: {labelColor};
27+
"
28+
>
29+
{#if tooltipSnippet === undefined}
30+
<div
31+
style="background-color: {labelColor};
2932
padding: 5px;
30-
border-radius: 5px;
31-
height={textDimensions?.height ?? 0}
32-
width={textDimensions?.width ?? 0}"
33-
>
34-
<div bind:contentRect={textDimensions}>{activeMarkerId.y}</div>
35-
</div>
36-
{:else}<div
37-
style="position: absolute; top: {markerRect?.y}px; left: {markerRect?.x}px;"
38-
>
39-
{@render tooltipSnippet(activeMarkerId)}
40-
</div>
41-
{/if}
33+
border-radius: 5px;"
34+
>
35+
<div bind:contentRect={textDimensions}>{activeMarkerId.y}</div>
36+
</div>
37+
{:else}
38+
<div bind:contentRect={textDimensions}>
39+
{@render tooltipSnippet(activeMarkerId)}
40+
</div>
41+
{/if}
42+
</div>

0 commit comments

Comments
 (0)