Skip to content

Commit 92c06e1

Browse files
committed
fix: improve chart type logic
1 parent ba82454 commit 92c06e1

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

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

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -98,21 +98,11 @@ export class ChartExtraTooltip extends AsyncStore<ReactiveTooltipState> {
9898
}
9999

100100
private onRenderTooltip = (props: { point: null | Highcharts.Point; group: readonly Highcharts.Point[] }) => {
101-
let hasPieSeries = false;
102-
let hasSolidGaugeSeries = false;
103-
for (const s of this.context.chart().series) {
104-
if (s.type === "pie") {
105-
hasPieSeries = true;
106-
break;
107-
}
108-
if (s.type === "solidgauge") {
109-
hasSolidGaugeSeries = true;
110-
break;
111-
}
112-
}
113-
if (hasPieSeries) {
101+
const chartType =
102+
this.context.chart().series.find((s) => s.type === "pie" || s.type === "solidgauge")?.type ?? "cartesian";
103+
if (chartType === "pie") {
114104
return this.onRenderTooltipPie(props.group[0]);
115-
} else if (hasSolidGaugeSeries) {
105+
} else if (chartType === "solidgauge") {
116106
return this.onRenderTooltipSolidGauge(props.group[0]);
117107
} else {
118108
return this.onRenderTooltipCartesian(props);

0 commit comments

Comments
 (0)