Created
April 22, 2016 19:47
-
-
Save 5tefan/542213e426693cd94da7ac80f530a135 to your computer and use it in GitHub Desktop.
Custom Plotlyjs bundle with Browerify for standalone script
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
In a dedicated directory: | |
1. save custom-plotly.js and package.json | |
2. specify the traces you want inside custom-plotly.js | |
3. run `git clone [email protected]:plotly/plotly.js.git` | |
4. run `cd plotly.js && npm install && cd ..` to install plotly's dependencies | |
5. run `npm install && npm run build` to create custom-plotly.min.js | |
6. move custom-plotly.min.js to your project and add <script src="custom-plotly.min.js" charset="utf-8"></script> | |
7. profit? global `Plotly` available. |
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
// in custom-plotly.js | |
var Plotly = require('./plotly.js/lib/core'); | |
// // Load in the trace types you need from lib | |
Plotly.register([ | |
require('./plotly.js/lib/scatter'), | |
// ... | |
]); | |
module.exports = Plotly; |
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": "custom-plotly", | |
"version": "1.0.0", | |
"description": "Custom Plotlyjs bundle with Browerify for standalone script", | |
"main": "custom-plotly.js", | |
"dependencies": {}, | |
"devDependencies": { | |
"browserify": "^13.0.0", | |
"uglify-js": "^2.6.2" | |
}, | |
"scripts": { | |
"build": "browserify custom-plotly.js --standalone Plotly | uglifyjs > custom-plotly.min.js", | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "5tefan", | |
"license": "ISC" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment