Skip to content

Typing for plotly_relayout event excludes autosize event #170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rageycomma opened this issue Dec 16, 2019 · 1 comment
Closed

Typing for plotly_relayout event excludes autosize event #170

rageycomma opened this issue Dec 16, 2019 · 1 comment

Comments

@rageycomma
Copy link

The typings for the relayout event omit the fact that an "autosize: true" event can be emitted by plotly.js. For instance, plotly's resize handler does the following:

plots.resize = function(gd) {
    gd = Lib.getGraphDiv(gd);

    return new Promise(function(resolve, reject) {
        if(!gd || Lib.isHidden(gd)) {
            reject(new Error('Resize must be passed a displayed plot div element.'));
        }

        if(gd._redrawTimer) clearTimeout(gd._redrawTimer);

        gd._redrawTimer = setTimeout(function() {
            // return if there is nothing to resize or is hidden
            if(!gd.layout || (gd.layout.width && gd.layout.height) || Lib.isHidden(gd)) {
                resolve(gd);
                return;
            }

            delete gd.layout.width;
            delete gd.layout.height;

            // autosizing doesn't count as a change that needs saving
            var oldchanged = gd.changed;

            // nor should it be included in the undo queue
            gd.autoplay = true;

            Registry.call('relayout', gd, {autosize: true}).then(function() {
                gd.changed = oldchanged;
                resolve(gd);
            });
        }, 100);
    });
};

This call passes {autosize: true} to the plotly_relayout event, however, the typings say:

onRelayout?: (event: Readonly<Plotly.PlotRelayoutEvent>) => void;

Which in plotly is:

export interface PlotRelayoutEvent {
	xaxis: PlotAxis;
	yaxis: PlotAxis;
	scene: PlotScene;
}
@etpinard
Copy link
Contributor

Hi, the plotly.js team does not actively maintain the typescript typings (more info in plotly/plotly.js#28)

I'd recommend opening an issue over at https://github.com/DefinitelyTyped/DefinitelyTyped

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants