You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Read the [Getting started page](https://plot.ly/javascript/getting-started/) for more examples.
44
48
45
49
## Modules
46
50
47
-
If you would like to reduce the bundle size of plotly.js, you can create a "custom" bundle by using `plotly.js/lib/core`, and loading only the trace types that you need (e.g. `pie` or `choropleth`). The recommended way to do this is by creating a "bundling file":
51
+
If you would like to reduce the bundle size of plotly.js, you can create a *custom* bundle by using `plotly.js/lib/core`, and loading only the trace types that you need (e.g. `pie` or `choropleth`). The recommended way to do this is by creating a *bundling file*:
48
52
49
53
```javascript
50
-
// custom-plotly.js
54
+
//in custom-plotly.js
51
55
var plotlyCore =require('plotly.js/lib/core');
52
56
53
57
// Load in the trace types for pie, and choropleth
54
58
plotlyCore.register([
55
-
require('plotly.js/lib/pie');
59
+
require('plotly.js/lib/pie'),
56
60
require('plotly.js/lib/choropleth');
57
61
]);
58
62
59
63
module.exports= customPlotly;
60
64
```
65
+
61
66
Then elsewhere in your code:
62
67
63
68
```javascript
64
-
var Plotly =require('./custom-plotly');
69
+
var Plotly =require('./path/to/custom-plotly');
65
70
```
66
71
72
+
**IMPORTANT**: the plotly.js code base contains some non-ascii characters. Therefore, please make sure to set the `chartset` attribute to `"utf-8"` in the script tag that imports your plotly.js bundle. For example:
Plotly.js uses a browserify transform (glslify) to transform shaders. To make the trace module system work with Webpack, you will need to install [ify-loader]() and add it to your `webpack.config.json` for your build to correctly bundle and parse `.glsl` files.
81
+
Browserify [transforms](https://github.com/substack/browserify-handbook#transforms) are required to build plotly.js, namely, [glslify](https://github.com/stackgl/glslify) to transform WebGL shaders and [cwise](https://github.com/scijs/cwise) to compile component-wise array operations. To make the trace module system work with Webpack, you will need to install [ify-loader](https://github.com/hughsk/ify-loader) and add it to your `webpack.config.json` for your build to correctly bundle plotly.js files.
0 commit comments