Skip to content

Commit

Permalink
fix(tooltip): Fix tooltip y coordinate with arc.rangeText
Browse files Browse the repository at this point in the history
- Adjust tooltip y coordinate position with combination of
arc.rangeText + title.text in gauge type
- Split tooltip position related test in separate file

Fix #3673
  • Loading branch information
netil authored Feb 29, 2024
1 parent 28a4506 commit d28258e
Show file tree
Hide file tree
Showing 3 changed files with 999 additions and 902 deletions.
16 changes: 10 additions & 6 deletions src/ChartInternal/internals/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,8 @@ export default {
{top: number, left: number} {
const $$ = this;
const {config, scale, state} = $$;
const {width, height, current, isLegendRight, inputType} = state;
const {width, height, current, hasRadar, hasTreemap, isLegendRight, inputType} = state;
const hasGauge = $$.hasType("gauge") && !config.gauge_fullCircle;
const hasTreemap = state.hasTreemap;
const hasRadar = state.hasRadar;
const isRotated = config.axis_rotated;
const hasArcType = $$.hasArcType();
const svgLeft = $$.getSvgLeft(true);
Expand All @@ -342,11 +340,17 @@ export default {
x += x >= (width / 2) ? 15 : -(tWidth + 15);
y += 15;
} else if (hasArcType) {
const raw = inputType === "touch";
const notTouch = inputType !== "touch";

if (notTouch) {
let titlePadding = $$.getTitlePadding?.() ?? 0;

if (titlePadding && hasGauge && config.arc_rangeText_values?.length) {
titlePadding += 10;
}

if (!raw) {
x += (width - (isLegendRight ? $$.getLegendWidth() : 0)) / 2;
y += (hasGauge ? height : (height / 2) + tHeight) + ($$.getTitlePadding?.() ?? 0);
y += (hasGauge ? height : (height / 2) + tHeight) + titlePadding;
}
} else if (hasTreemap) {
y += tHeight;
Expand Down
Loading

0 comments on commit d28258e

Please sign in to comment.