diff --git a/src/ChartInternal/internals/size.ts b/src/ChartInternal/internals/size.ts index b6e1cbb7d..8281f9f94 100644 --- a/src/ChartInternal/internals/size.ts +++ b/src/ChartInternal/internals/size.ts @@ -86,16 +86,18 @@ export default { getSvgLeft(withoutRecompute?: boolean): number { const $$ = this; - const {config, $el} = $$; + const {config, state: {hasAxis}, $el} = $$; const isRotated = config.axis_rotated; const hasLeftAxisRect = isRotated || (!isRotated && !config.axis_y_inner); const leftAxisClass = isRotated ? $AXIS.axisX : $AXIS.axisY; const leftAxis = $el.main.select(`.${leftAxisClass}`).node(); - const leftLabel = config[`axis_${isRotated ? "x" : "y"}_label`]; + const leftLabel = hasAxis && config[`axis_${isRotated ? "x" : "y"}_label`]; let labelWidth = 0; // if axis label position set to inner, exclude from the value - if (isString(leftLabel) || isString(leftLabel.text) || /^inner-/.test(leftLabel?.position)) { + if (hasAxis && ( + isString(leftLabel) || isString(leftLabel.text) || /^inner-/.test(leftLabel?.position) + )) { const label = $el.main.select(`.${leftAxisClass}-label`); if (!label.empty()) { diff --git a/test/esm/donut-spec.ts b/test/esm/donut-spec.ts index 43ba6ca9f..a2e45a43e 100644 --- a/test/esm/donut-spec.ts +++ b/test/esm/donut-spec.ts @@ -43,4 +43,12 @@ describe("ESM donut", function() { done(); }, 500); }); + + it("shouldn't throw error on call of tooltip API.", () => { + delete chart.internal.config.axis_y_label; + + chart.tooltip.show({x:0}); + + chart.internal.config.axis_y_label = {}; + }); });