Skip to content
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

Changing interactionModel through updateOptions does not work #1020

Open
ElementW opened this issue Jun 2, 2022 · 0 comments
Open

Changing interactionModel through updateOptions does not work #1020

ElementW opened this issue Jun 2, 2022 · 0 comments

Comments

@ElementW
Copy link

ElementW commented Jun 2, 2022

What was expected: g.updateOptions({ interactionModel: ... }) changes g's interaction model.
What happened: Interaction model stays unchanged.

A comment in dygraph-interaction-model.js:625-633 suggests that using g.updateOptions() to change the current interactionModel is possible:

/**
 * Default interation model for dygraphs. You can refer to specific elements of
 * this when constructing your own interaction model, e.g.:
 * g.updateOptions( {
 *   interactionModel: {
 *     mousedown: DygraphInteraction.defaultInteractionModel.mousedown
 *   }
 * } );
 */

However, dygraphs.js' structure does not allow for the dynamic change of interaction model, as it is set up in createDragInterface_(), which is only ever called once, in __init__(), and not when options are updated.

Furthermore, createDragInterface_() calls into addAndTrackEvent(), and there is no way of removing a previously added event callback aside from removing them all with removeTrackedEvents_(); thus calling createDragInterface_() again is unsuitable. That said the event it adds are wrapped (to bind this), so could be extended to act as proxies to the current, uncached interaction model.

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

1 participant