diff --git a/src/ChartInternal/interactions/interaction.ts b/src/ChartInternal/interactions/interaction.ts index 3099462b9..34e9dacaa 100644 --- a/src/ChartInternal/interactions/interaction.ts +++ b/src/ChartInternal/interactions/interaction.ts @@ -104,7 +104,7 @@ export default { $$.cache.add(KEY.setOverOut, last); } else { if (isOver) { - $$.isPointFocusOnly() && hasRadar ? + hasRadar && $$.isPointFocusOnly() ? $$.showCircleFocus($$.getAllValuesOnIndex(d, true)) : $$.setExpand(d, null, true); } diff --git a/src/ChartInternal/internals/selection.ts b/src/ChartInternal/internals/selection.ts index 54b40e4a6..998235ff6 100644 --- a/src/ChartInternal/internals/selection.ts +++ b/src/ChartInternal/internals/selection.ts @@ -160,7 +160,7 @@ export default { let toggledShape; if (!config.data_selection_multiple) { - const focusOnly = $$.isPointFocusOnly(); + const focusOnly = $$.isPointFocusOnly?.(); let selector = `.${focusOnly ? $SELECT.selectedCircles : $SHAPE.shapes}`; if (config.data_selection_grouped) { diff --git a/src/ChartInternal/shape/point.ts b/src/ChartInternal/shape/point.ts index 0aabbd74b..6e074624e 100644 --- a/src/ChartInternal/shape/point.ts +++ b/src/ChartInternal/shape/point.ts @@ -43,7 +43,7 @@ export default { let opacity = config.point_opacity; if (isUndefined(opacity)) { - opacity = config.point_show && !this.isPointFocusOnly() ? null : "0"; + opacity = config.point_show && !this.isPointFocusOnly?.() ? null : "0"; opacity = isValue(this.getBaseValue(d)) ? (this.isBubbleType(d) || this.isScatterType(d) ? @@ -210,7 +210,7 @@ export default { const {state: {hasRadar, resizing, toggling, transiting}, $el} = $$; let {circle} = $el; - if (transiting === false && $$.isPointFocusOnly() && circle) { + if (transiting === false && circle && $$.isPointFocusOnly()) { const cx = (hasRadar ? $$.radarCircleX : $$.circleX).bind($$); const cy = (hasRadar ? $$.radarCircleY : $$.circleY).bind($$); const withTransition = toggling || isUndefined(d); diff --git a/src/Plugin/sparkline/index.ts b/src/Plugin/sparkline/index.ts index b5ed2b4f5..344771ee5 100644 --- a/src/Plugin/sparkline/index.ts +++ b/src/Plugin/sparkline/index.ts @@ -222,7 +222,7 @@ export default class Sparkline extends Plugin { $$.state.event = e; - if ($$.isPointFocusOnly() && d) { + if ($$.isPointFocusOnly?.() && d) { $$.showCircleFocus?.([d]); } diff --git a/test/esm/bar-spec.ts b/test/esm/bar-spec.ts index 42b0528ba..b9a5419a9 100644 --- a/test/esm/bar-spec.ts +++ b/test/esm/bar-spec.ts @@ -111,5 +111,20 @@ describe("ESM bar", function() { proto.showCircleFocus = fn; }); + + it("shoudn't throw error on tooltip show", () => { + const proto = Object.getPrototypeOf(chart.internal); + const {isPointFocusOnly} = proto; + + // delete temporarly for test + delete proto.isPointFocusOnly; + + expect( + chart.tooltip.show({x: 2}) + ).to.not.throw; + + // restore + proto.isPointFocusOnly = isPointFocusOnly; + }); }); }); \ No newline at end of file