Skip to content

Instantly share code, notes, and snippets.

@5tefan
Created April 22, 2016 19:47
Show Gist options
  • Save 5tefan/542213e426693cd94da7ac80f530a135 to your computer and use it in GitHub Desktop.
Save 5tefan/542213e426693cd94da7ac80f530a135 to your computer and use it in GitHub Desktop.
Custom Plotlyjs bundle with Browerify for standalone script
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.
// 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;
{
"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