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
Copy file name to clipboardExpand all lines: README.md
+39-21Lines changed: 39 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -70,36 +70,54 @@ and use the plotly.js `dist` file(s). More info [here](https://github.com/plotly
70
70
71
71
#### Read the [Getting started page](https://plotly.com/javascript/getting-started/) for more examples.
72
72
73
-
## Modules
73
+
## Partial bundles
74
74
75
-
Starting in `v1.15.0`, plotly.js ships with several _partial_ bundles (more info [here](https://github.com/plotly/plotly.js/blob/master/dist/README.md#partial-bundles)).
75
+
There are two kinds of plotly.js partial bundles:
76
+
1. The official partial bundles that are distributed to `npm` and the CDN, described in [the dist README](https://github.com/plotly/plotly.js/blob/master/dist/README.md).
77
+
2. Custom bundles you can create yourself, if none of the distributed packages meet your needs.
76
78
77
-
Starting in `v1.39.0`, plotly.js publishes _distributed_ npm packages with no dependencies. For example, run `npm install plotly.js-geo-dist` and add `import Plotly from 'plotly.js-geo-dist';` to your code to start using the plotly.js geo package.
78
-
79
-
If none of the distributed npm packages meet your needs, and you would like to manually pick which plotly.js modules to include, you'll first need to run `npm install plotly.js` and then 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*. For example, in CommonJS:
80
-
81
-
```javascript
82
-
// in custom-plotly.js
83
-
var Plotly =require('plotly.js/lib/core');
84
-
85
-
// Load in the trace types for pie, and choropleth
86
-
Plotly.register([
87
-
require('plotly.js/lib/pie'),
88
-
require('plotly.js/lib/choropleth')
89
-
]);
79
+
Use the `traces` option to include just the trace types you need.
80
+
```
81
+
npm run partial-bundle -- --traces scatter,scattergl,scatter3d
82
+
```
83
+
Please note that the `scatter` trace is currently included in all bundles and cannot be removed.
84
+
[This behaviour may change in the future](https://github.com/plotly/plotly.js/pull/5535), so we recommend that you explicitly include `scatter` anyway if you need it in your bundle.
90
85
91
-
module.exports= Plotly;
86
+
By default all transforms are included in the bundle.
87
+
Use the `transforms` option to specify which should be included.
88
+
```
89
+
npm run partial-bundle -- --transforms sort,filter
92
90
```
93
91
94
-
Then elsewhere in your code:
92
+
Or use `transforms none` to exclude them all.
93
+
```
94
+
npm run partial-bundle -- --transforms none
95
+
```
95
96
96
-
```javascript
97
-
var Plotly =require('./path/to/custom-plotly');
97
+
Use the `out` option to change the bundle filename (default `custom`).
98
+
The new bundle will be created in the `dist/` directory and named `plotly-<out>.min.js` or `plotly-<out>.js` if unminified.
99
+
```
100
+
npm run partial-bundle -- --out myBundleName
98
101
```
99
102
100
-
Alternatively you could browserify a custom bundle of desired trace modules e.g. `pie` and `choropleth` using
101
-
`npm run partial-bundle pie choropleth --name=custom`
103
+
Use the `unminified` option to disable compression.
104
+
```
105
+
npm run partial-bundle -- --unminified
106
+
```
102
107
108
+
### Example illustrating use of different options together
109
+
To create an unminified custom bundle named `myScatters` including `scatter`, `scattergl` and `scatter3d` traces without any transforms:
0 commit comments