@internetstiftelsen/charts 0.19.2 → 0.19.3
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.
package/dist/tooltip/geometry.js
CHANGED
|
@@ -725,7 +725,7 @@ function getHorizontalAboveBelowPlacementCost(candidate, layout, preferredEdge,
|
|
|
725
725
|
return (connectorPenalty +
|
|
726
726
|
edgePenalty +
|
|
727
727
|
xDistance +
|
|
728
|
-
yDistance *
|
|
728
|
+
yDistance * 4 +
|
|
729
729
|
overflowPenalty);
|
|
730
730
|
}
|
|
731
731
|
function getPreferredAndOppositeEdges(preferredEdge) {
|
|
@@ -757,8 +757,9 @@ function getTooltipPlacementBounds(svgNode) {
|
|
|
757
757
|
let bounds = getSplitTooltipViewportBounds();
|
|
758
758
|
let currentElement = svgNode.parentElement;
|
|
759
759
|
while (currentElement) {
|
|
760
|
-
|
|
761
|
-
|
|
760
|
+
const scrollAxes = getScrollableElementAxes(currentElement);
|
|
761
|
+
if (scrollAxes.horizontal || scrollAxes.vertical) {
|
|
762
|
+
bounds = intersectTooltipBounds(bounds, getElementTooltipBounds(currentElement), scrollAxes);
|
|
762
763
|
}
|
|
763
764
|
currentElement = currentElement.parentElement;
|
|
764
765
|
}
|
|
@@ -775,15 +776,26 @@ function getElementTooltipBounds(element) {
|
|
|
775
776
|
maxBottom: top + rect.height,
|
|
776
777
|
};
|
|
777
778
|
}
|
|
778
|
-
function intersectTooltipBounds(bounds, nextBounds
|
|
779
|
+
function intersectTooltipBounds(bounds, nextBounds, axes = {
|
|
780
|
+
horizontal: true,
|
|
781
|
+
vertical: true,
|
|
782
|
+
}) {
|
|
779
783
|
if (nextBounds.maxRight <= nextBounds.minLeft ||
|
|
780
784
|
nextBounds.maxBottom <= nextBounds.minTop) {
|
|
781
785
|
return bounds;
|
|
782
786
|
}
|
|
783
|
-
const minLeft =
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
const
|
|
787
|
+
const minLeft = axes.horizontal
|
|
788
|
+
? Math.max(bounds.minLeft, nextBounds.minLeft)
|
|
789
|
+
: bounds.minLeft;
|
|
790
|
+
const maxRight = axes.horizontal
|
|
791
|
+
? Math.min(bounds.maxRight, nextBounds.maxRight)
|
|
792
|
+
: bounds.maxRight;
|
|
793
|
+
const minTop = axes.vertical
|
|
794
|
+
? Math.max(bounds.minTop, nextBounds.minTop)
|
|
795
|
+
: bounds.minTop;
|
|
796
|
+
const maxBottom = axes.vertical
|
|
797
|
+
? Math.min(bounds.maxBottom, nextBounds.maxBottom)
|
|
798
|
+
: bounds.maxBottom;
|
|
787
799
|
if (maxRight <= minLeft || maxBottom <= minTop) {
|
|
788
800
|
return bounds;
|
|
789
801
|
}
|
|
@@ -820,6 +832,26 @@ function getTooltipScrollTargets(svgNode) {
|
|
|
820
832
|
return [...scrollTargets];
|
|
821
833
|
}
|
|
822
834
|
function isScrollableElement(element) {
|
|
835
|
+
const scrollAxes = getScrollableElementAxes(element);
|
|
836
|
+
return scrollAxes.horizontal || scrollAxes.vertical;
|
|
837
|
+
}
|
|
838
|
+
function getScrollableElementAxes(element) {
|
|
823
839
|
const style = window.getComputedStyle(element);
|
|
824
|
-
return
|
|
840
|
+
return {
|
|
841
|
+
horizontal: isScrollableOverflowValue(style.overflowX) &&
|
|
842
|
+
hasScrollableOverflow(element, 'horizontal'),
|
|
843
|
+
vertical: isScrollableOverflowValue(style.overflowY) &&
|
|
844
|
+
hasScrollableOverflow(element, 'vertical'),
|
|
845
|
+
};
|
|
846
|
+
}
|
|
847
|
+
function isScrollableOverflowValue(value) {
|
|
848
|
+
return value === 'auto' || value === 'scroll' || value === 'overlay';
|
|
849
|
+
}
|
|
850
|
+
function hasScrollableOverflow(element, axis) {
|
|
851
|
+
const scrollSize = axis === 'horizontal' ? element.scrollWidth : element.scrollHeight;
|
|
852
|
+
const clientSize = axis === 'horizontal' ? element.clientWidth : element.clientHeight;
|
|
853
|
+
if (scrollSize === 0 && clientSize === 0) {
|
|
854
|
+
return true;
|
|
855
|
+
}
|
|
856
|
+
return scrollSize > clientSize;
|
|
825
857
|
}
|
package/package.json
CHANGED