Skip to content

Commit

Permalink
fix(tooltip): Fix tooltip error on Arc type
Browse files Browse the repository at this point in the history
Side effect caused by #3475.
The condition set where valid only for axis based chart

Fix #3473 (comment)
  • Loading branch information
netil authored Oct 26, 2023
1 parent 79c3cfc commit 5e80d9d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/ChartInternal/internals/size.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
10 changes: 10 additions & 0 deletions test/esm/donut-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,14 @@ describe("ESM donut", function() {
done();
}, 500);
});

it("shouldn't throw error on call of tooltip API.", () => {
delete chart.internal.config.axis_y_label;

expect(
chart.tooltip.show({x:0})
).to.not.throw;

chart.internal.config.axis_y_label = {};
});
});

0 comments on commit 5e80d9d

Please sign in to comment.