Created
May 5, 2017 23:13
-
-
Save etpinard/bb51194651cdb40fa7bcb1f35c34963e to your computer and use it in GitHub Desktop.
plotly.js use modebar buttons handlers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node_modules | |
bundle.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<body> | |
<script src="bundle.js"></script> | |
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Plotly = require('plotly.js') | |
var ModeBarButtons = require('plotly.js/src/components/modebar/buttons.js') | |
var gd = document.createElement('div') | |
var btn = document.createElement('button') | |
document.body.appendChild(gd) | |
document.body.appendChild(btn) | |
Plotly.newPlot(gd, [{ | |
y: [1, 2, 1], | |
line: { shape: 'spline' } | |
}]) | |
btn.innerHTML = 'RESET' | |
btn.setAttribute('data-attr', 'zoom') | |
btn.setAttribute('data-val', 'reset') | |
btn.onclick = function (ev) { | |
ModeBarButtons.resetScale2d.click(gd, ev) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "plotly.js-use-modebar-buttons-handlers", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"build": "browserify index.js > bundle.js", | |
"start": "http-server -p 9999" | |
}, | |
"keywords": [], | |
"author": "Étienne Tétreault-Pinard <etienne.t.pinard@gmail.com>", | |
"license": "MIT", | |
"dependencies": { | |
"browserify": "^14.3.0", | |
"http-server": "^0.10.0", | |
"plotly.js": "^1.26.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment