Skip to content

Commit 067f70d

Browse files
authored
fix: Fixes tooltip placement in React 16 and 17 (#112)
1 parent 50fd078 commit 067f70d

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/core/chart-api/chart-extra-tooltip.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,15 @@ export class ChartExtraTooltip extends AsyncStore<ReactiveTooltipState> {
7171

7272
public showTooltipOnPoint(point: Highcharts.Point, matchingGroup: readonly Highcharts.Point[], ignoreLock = false) {
7373
if (!this.tooltipLock || ignoreLock) {
74+
this.updateTooltipCursor({ point, group: matchingGroup });
7475
this.set(() => ({ visible: true, pinned: false, point, group: matchingGroup }));
75-
this.onRenderTooltip({ point, group: matchingGroup });
7676
}
7777
}
7878

7979
public showTooltipOnGroup(group: readonly Highcharts.Point[], ignoreLock = false) {
8080
if (!this.tooltipLock || ignoreLock) {
81+
this.updateTooltipCursor({ point: null, group });
8182
this.setGroupIfDifferent(group);
82-
this.onRenderTooltip({ point: null, group });
8383
}
8484
}
8585

@@ -110,19 +110,19 @@ export class ChartExtraTooltip extends AsyncStore<ReactiveTooltipState> {
110110
});
111111
}
112112

113-
private onRenderTooltip = (props: { point: null | Highcharts.Point; group: readonly Highcharts.Point[] }) => {
113+
private updateTooltipCursor = (props: { point: null | Highcharts.Point; group: readonly Highcharts.Point[] }) => {
114114
const chartType =
115115
this.context.chart().series.find((s) => s.type === "pie" || s.type === "solidgauge")?.type ?? "cartesian";
116116
if (chartType === "pie") {
117-
return this.onRenderTooltipPie(props.group[0]);
117+
return this.updateTooltipCursorPie(props.group[0]);
118118
} else if (chartType === "solidgauge") {
119-
return this.onRenderTooltipSolidGauge(props.group[0]);
119+
return this.updateTooltipCursorGauge(props.group[0]);
120120
} else {
121-
return this.onRenderTooltipCartesian(props);
121+
return this.updateTooltipCursorCartesian(props);
122122
}
123123
};
124124

125-
private onRenderTooltipCartesian = ({
125+
private updateTooltipCursorCartesian = ({
126126
point,
127127
group,
128128
}: {
@@ -138,14 +138,14 @@ export class ChartExtraTooltip extends AsyncStore<ReactiveTooltipState> {
138138
this.groupTrack.rect(this.context.chart().renderer, { ...groupRect, ...this.commonTrackAttrs });
139139
};
140140

141-
private onRenderTooltipPie = (point: Highcharts.Point) => {
141+
private updateTooltipCursorPie = (point: Highcharts.Point) => {
142142
// We only create target track for pie chart as pie chart does not support groups.
143143
// It is also expected that only "target" tooltip position is used for pie charts.
144144
const pointRect = getPieChartTargetPlacement(point);
145145
this.targetTrack.rect(this.context.chart().renderer, { ...pointRect, ...this.commonTrackAttrs });
146146
};
147147

148-
private onRenderTooltipSolidGauge = (point: Highcharts.Point) => {
148+
private updateTooltipCursorGauge = (point: Highcharts.Point) => {
149149
// Solid gauge charts are similar to pie charts in that they have a circular shape
150150
// and don't support grouping. We use a similar approach to pie charts.
151151
const pointRect = getSolidGaugeTargetPlacement(point);

0 commit comments

Comments
 (0)