Skip to content

Instantly share code, notes, and snippets.

@hy9be
Forked from 5tefan/README
Last active December 27, 2016 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hy9be/2bb059b158a08e7dd6cfa83e20376810 to your computer and use it in GitHub Desktop.
Save hy9be/2bb059b158a08e7dd6cfa83e20376810 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 git@github.com: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('../lib/bar'),
require('../lib/scatter'),
require('../lib/scattergl'),
require('../lib/pie')
]);
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