Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
plotly.js use modebar buttons handlers
node_modules
bundle.js
<body>
<script src="bundle.js"></script>
</body>
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)
}
{
"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
You can’t perform that action at this time.