plotly / plotly/react-plotly.js

how to use modebar buttons handlers

Open
#100 0 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
1.1k
Forks
138
Avg merge
3d 2h
Merged PRs (30d)
4

Description

I am using "react-plotly.js": "^2.2.0" ,

  1. I am using react Image component
  2. on click of image i am calling ResetOnly(event) {
    var plotDiv = document.getElementsByClassName('plot-chart-class1');
    //var button = event.currentTarget;
    // button.setAttribute('data-attr', 'zoom');
    // button.setAttribute('data-val', 'reset');
    ModeBarButtons.zoomIn2d.click(plotDiv[0], event);
    }
  3. i have imported import ModeBarButtons from 'plotly.js/src/components/modebar/buttons.js';
  4. I am getting this error
    registry.js:221 Uncaught TypeError: Cannot read property 'apply' of undefined
    at Object.exports.call (registry.js:221)
    at Object.handleCartesian [as click] (buttons.js:264)
    at PlotlyChart.ResetOnly (PlotlyChart.jsx:342)
    at HTMLUnknownElement.boundFunc (ReactErrorUtils.js:63)
    at Object.ReactErrorUtils.invokeGuardedCallback (ReactErrorUtils.js:69)
    at executeDispatch (EventPluginUtils.js:83)
    at Object.executeDispatchesInOrder (EventPluginUtils.js:106)
    at executeDispatchesAndRelease (EventPluginHub.js:41)
    at executeDispatchesAndReleaseTopLevel (EventPluginHub.js:52)
    at Array.forEach ()
  5. In registry.js file, in below function exports.apiMethodRegistry[name] is undefined
    exports.call = function() {
    var name = arguments[0];
    var args = [].slice.call(arguments, 1);
    return exports.apiMethodRegistry[name].apply(null, args);
    };
    can someone help me to resolve this issue

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the modebar button click in PlotlyChart.jsx using the react-plotly.js setup described. Read plotly.js/src/components/modebar/buttons.js and registry.js around the failing call, then determine why the referenced API method is undefined; done means the handler executes without the registry error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
data-visualization, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.