Skip to content

Commit da18084

Browse files
committed
place tooltip above line of line chart, otherwise fall back to 50% bottom position (default)
1 parent b255cb8 commit da18084

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/components/_tooltips.scss

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@
77
// Position
88
position: absolute;
99
z-index: 1;
10-
inset-block-end: 50%;
10+
// if --start / --end exist, then it's a line chart, and we calculate
11+
// the larger of the two to place the tooltip above the line segment;
12+
// if --start and --end don't exist, fallback to 0.5 * 100% = 50%,
13+
// which is the default tooltip position for e.g. bar charts
14+
inset-block-end: calc(max(var(--start, 0.5), var(--end, 0.5)) * 100%);
1115
inset-inline-start: 50%;
16+
transform: translateX(-50%); // translateX for both bar & column chart
1217
width: max-content;
1318
padding: 5px 10px;
1419
border-radius: 6px;

0 commit comments

Comments
 (0)