apache/echarts · error

axisPointer {} exists

Error message

axisPointer {} exists

What it means

DEV-only guard in AxisView.registerAxisPointerClass: axis pointer implementations live in a module-level registry keyed by type. Registering the same type string twice throws in dev to catch accidental double-registration. Stripped in production (second registration silently overwrites).

Source

Thrown at src/component/axis/AxisView.ts:115

        if (!Clazz) {
            return;
        }
        const axisPointerModel = axisPointerModelHelper.getAxisPointerModel(axisModel);
        axisPointerModel
            ? (this._axisPointer || (this._axisPointer = new Clazz()))
                .render(axisModel, axisPointerModel, api, forceRender)
            : this._disposeAxisPointer(api);
    }

    private _disposeAxisPointer(api: ExtensionAPI) {
        this._axisPointer && this._axisPointer.dispose(api);
        this._axisPointer = null;
    }

    static registerAxisPointerClass(type: string, clazz: AxisPointerConstructor) {
        if (__DEV__) {
            if (axisPointerClazz[type]) {
                throw new Error('axisPointer ' + type + ' exists');
            }
        }
        axisPointerClazz[type] = clazz;
    };

    static getAxisPointerClass(type: string) {
        return type && axisPointerClazz[type];
    };

}

export default AxisView;

View on GitHub (pinned to 30076aedcd)

Solutions

  1. Use a unique, namespaced type string for custom axis pointers
  2. Guard registration with a getAxisPointerClass(type) existence check first
  3. Ensure the registration module is imported exactly once (avoid HMR double-eval)

Example fix

// before
AxisView.registerAxisPointerClass('cross', MyCrossPointer); // 'cross' taken

// after
if (!AxisView.getAxisPointerClass('myCross')) {
  AxisView.registerAxisPointerClass('myCross', MyCrossPointer);
}
Defensive patterns

Strategy: validation

Validate before calling

// before registering an axis pointer class, check existence:
if (!AxisView.getAxisPointerClass(type)) {
  AxisView.registerAxisPointerClass(type, Clazz);
}

Prevention

When it happens

Trigger: Calling echarts.registerAxisPointerClass (or an internal equivalent) with a type name that is already registered; HMR/hot-reload re-executing registration code; a custom extension reusing a built-in type string like 'cross' or 'shadow'.

Common situations: Vite/webpack HMR re-running the registration module; custom axis-pointer extension colliding with a built-in type; double import of an extension.

Related errors


AI-assisted analysis of apache/echarts@30076aedcd (2026-08-12). Data as JSON: /api/errors/5c82885783eb8b76. Report an issue: GitHub.