Skip to content

Changing interactionModel through updateOptions does not work #1020

@ElementW

Description

@ElementW

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions