Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fixed tooltip for Mobile Area Charts #1817

Merged
merged 11 commits into from
Nov 11, 2024
4 changes: 3 additions & 1 deletion app/charts/combo/combo-line-dual-state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ const useComboLineDualState = (
};
})
.filter(truthy);
const yAnchor = isMobile ? chartHeight : mean(values.map((d) => d.yPos));
const yAnchor = isMobile
? chartHeight + 32
noahonyejese marked this conversation as resolved.
Show resolved Hide resolved
: mean(values.map((d) => d.yPos));
const placement: TooltipPlacement = isMobile
? { x: "center", y: "bottom" }
: getCenteredTooltipPlacement({
Expand Down
15 changes: 15 additions & 0 deletions app/charts/shared/interaction/tooltip-box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,21 @@ const triangleXPos = (
tooltipWidth: number,
chartWidth: number
): number => {
if (chartWidth < tooltipWidth) {
const maxPosition = chartWidth + TRIANGLE_SIZE;
noahonyejese marked this conversation as resolved.
Show resolved Hide resolved

return Math.min(
Math.max(
value,
Math.min(
tooltipWidth / 2 - TRIANGLE_SIZE,
Math.min(chartWidth - tooltipWidth / 2 + TRIANGLE_SIZE, value)
)
),
maxPosition
);
}

const condition = chartWidth - tooltipWidth / 2 + TRIANGLE_SIZE < value;
noahonyejese marked this conversation as resolved.
Show resolved Hide resolved

if (condition) {
Expand Down
Loading