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: BUILDING.md
+6-5
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,7 @@
1
1
# Alternative ways to require or build plotly.js
2
-
Depending on your needs, to bundle plotly.js into your application one of [the browserified distributed plotly.js packages](https://github.com/plotly/plotly.js/blob/master/dist/README.md) on npm could be used.
2
+
Depending on your needs you may require/import one of [the distributed plotly.js packages](https://github.com/plotly/plotly.js/blob/master/dist/README.md) or [a plotly.js/lib index file](https://github.com/plotly/plotly.js/tree/master/lib) and integrate it into your application.
3
+
4
+
The sections below provide additional info in respect to alternative building frameworks.
3
5
4
6
## Browserify example
5
7
@@ -16,10 +18,7 @@ then simply run
16
18
browserify index.js > bundle.js
17
19
```
18
20
19
-
20
-
21
-
The sections below provide additional info in respect to alternative building frameworks.
22
-
21
+
---
23
22
## Webpack
24
23
25
24
For plotly.js to build with Webpack you will need to install [[email protected]+](https://github.com/hughsk/ify-loader) and add it to your `webpack.config.json`. This adds Browserify transform compatibility to Webpack which is necessary for some plotly.js dependencies.
@@ -39,6 +38,7 @@ A repo that demonstrates how to build plotly.js with Webpack can be found [here]
39
38
...
40
39
```
41
40
41
+
---
42
42
## Angular CLI
43
43
44
44
Since Angular uses webpack under the hood and doesn't allow easily to change it's webpack configuration, there is some work needed using a `custom-webpack` builder to get things going.
@@ -99,3 +99,4 @@ module.exports = {
99
99
100
100
It's important to set `projects.x.architect.build.builder` and `projects.x.architect.build.options.customWebpackConfig`.
101
101
If you have more projects in your `angular.json` make sure to adjust their settings accordingly.
You can simply make custom bundles yourself, if none of the [distributed packages](https://github.com/plotly/plotly.js/blob/master/dist/README.md) meet your needs, or you want to make a more optimized bundle file with/without specific traces and transforms.
3
+
4
+
Install plotly.js, move to plotly.js folder then install plotly.js dependencies:
By default all traces and transforms are included in the bundle if you simply run:
12
+
```sh
13
+
npm run partial-bundle
14
+
```
15
+
16
+
Use the `traces` option to include just the trace types you need.
17
+
```sh
18
+
npm run partial-bundle -- --traces scatter,scattergl,scatter3d
19
+
```
20
+
Please note that the `scatter` trace is currently included in all bundles and cannot be removed.
21
+
[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.
22
+
23
+
Use the `transforms` option to specify which should be included.
24
+
```sh
25
+
npm run partial-bundle -- --transforms sort,filter
26
+
```
27
+
28
+
Or use `transforms none` to exclude them all.
29
+
```sh
30
+
npm run partial-bundle -- --transforms none
31
+
```
32
+
33
+
Use the `out` option to change the bundle filename (default `custom`).
34
+
The new bundle will be created in the `dist/` directory and named `plotly-<out>.min.js` or `plotly-<out>.js` if unminified.
35
+
```sh
36
+
npm run partial-bundle -- --out myBundleName
37
+
```
38
+
39
+
Use the `unminified` option to disable compression.
40
+
```sh
41
+
npm run partial-bundle -- --unminified
42
+
```
43
+
44
+
# Example illustrating use of different options together
45
+
To create an unminified custom bundle named `myScatters` including `scatter`, `scattergl` and `scatter3d` traces without any transforms:
In the example above `Plotly` object is added to the window scope by the script in the `head` section.
75
+
The `newPlot` method is then used to draw an interactive figure as described by `data` and `layout` into the desired `div` here named `gd`.
76
+
As demonstrated in the example above basic knowledge of `html` and [JSON](https://en.wikipedia.org/wiki/JSON) syntax is enough to get started i.e. with/without JavaScript!
77
+
To learn and build more with plotly.js please visit [plotly.js documentation](https://plotly.com/javascript).
55
78
56
-
#### An un-minified version is also available
79
+
### Un-minified versions are also available on CDN
80
+
While non-minified source files may contain characters outside UTF-8, it is recommended that you specify the `charset` when loading those bundles.
##### Please note that as of v2 the "plotly-latest" outputs (e.g. https://cdn.plot.ly/plotly-latest.min.js) will no longer be updated on the CDN, and will stay at the last v1 patch v1.58.4. Therefore, to use the CDN with plotly.js v2 and higher, you must specify an exact plotly.js version.
64
-
65
-
Fastly supports Plotly.js with free CDN service. Read more at <https://www.fastly.com/open-source>
66
-
67
-
### Download the latest release or a release candidate (rc)
68
-
69
-
[Latest and rc releases on GitHub](https://github.com/plotly/plotly.js/releases/)
70
-
71
-
and use the plotly.js `dist` file(s). More info [here](https://github.com/plotly/plotly.js/blob/master/dist/README.md).
72
-
73
-
#### Read the [Getting started page](https://plotly.com/javascript/getting-started/) for more examples.
74
-
75
-
---
76
-
## Partial bundles
77
-
78
-
There are two kinds of plotly.js partial bundles:
79
-
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).
80
-
2. Custom bundles you can create yourself, if none of the distributed packages meet your needs.
81
-
82
-
Use the `traces` option to include just the trace types you need.
83
-
```sh
84
-
npm run partial-bundle -- --traces scatter,scattergl,scatter3d
85
-
```
86
-
Please note that the `scatter` trace is currently included in all bundles and cannot be removed.
87
-
[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.
88
-
89
-
By default all transforms are included in the bundle.
90
-
Use the `transforms` option to specify which should be included.
91
-
```sh
92
-
npm run partial-bundle -- --transforms sort,filter
Use the `out` option to change the bundle filename (default `custom`).
101
-
The new bundle will be created in the `dist/` directory and named `plotly-<out>.min.js` or `plotly-<out>.js` if unminified.
102
-
```sh
103
-
npm run partial-bundle -- --out myBundleName
104
-
```
85
+
> Please note that as of v2 the "plotly-latest" outputs (e.g. https://cdn.plot.ly/plotly-latest.min.js) will no longer be updated on the CDN, and will stay at the last v1 patch v1.58.4. Therefore, to use the CDN with plotly.js v2 and higher, you must specify an exact plotly.js version.
105
86
106
-
Use the `unminified` option to disable compression.
107
-
```sh
108
-
npm run partial-bundle -- --unminified
87
+
### To support MathJax
88
+
Load relevant MathJax (v2) files *Before* the plotly.js script tag:
1. Complete and partial official 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).
97
+
2. Custom bundles you can create yourself to optimize the size of bundle depending on your needs. Please visit [CUSTOM_BUNDLE](https://github.com/plotly/plotly.js/blob/master/CUSTOM_BUNDLE.md) for more information.
124
98
125
99
---
126
100
## Alternative ways to require or build plotly.js
127
101
If your library needs to bundle or directly require [plotly.js/lib/index.js](https://github.com/plotly/plotly.js/blob/master/lib/index.js) or parts of its modules similar to [index-basic](https://github.com/plotly/plotly.js/blob/master/lib/index-basic.js) in some other way than via an official or a custom bundle, or in case you want to tweak the default build configurations of `browserify` or `webpack`, etc. then please visit [`BUILDING.md`](https://github.com/plotly/plotly.js/blob/master/BUILDING.md).
128
102
129
-
---
130
-
## Bugs and feature requests
131
-
132
-
Have a bug or a feature request? Please [open a Github issue](https://github.com/plotly/plotly.js/issues/new) keeping in mind the [issue guidelines](https://github.com/plotly/plotly.js/blob/master/.github/ISSUE_TEMPLATE.md). You may also want to read about [how changes get made to Plotly.js](https://github.com/plotly/plotly.js/blob/master/CONTRIBUTING.md)
133
-
134
103
---
135
104
## Documentation
136
105
@@ -139,32 +108,16 @@ Official plotly.js documentation is hosted at [https://plotly.com/javascript](ht
139
108
These pages are generated by the Plotly [graphing-library-docs repo](https://github.com/plotly/graphing-library-docs) built with [Jekyll](https://jekyllrb.com/) and publicly hosted on GitHub Pages.
140
109
For more info about contributing to Plotly documentation, please read through [contributing guidelines](https://github.com/plotly/graphing-library-docs/blob/master/README.md).
141
110
142
-
### To support MathJax
143
-
Load relevant MathJax (v2) files *Before* the plotly.js script tag:
Please read through our [contributing guidelines](https://github.com/plotly/plotly.js/blob/master/CONTRIBUTING.md). Included are directions for opening issues, using plotly.js in your project and notes on development.
112
+
## Bugs and feature requests
153
113
154
-
---
155
-
## Community
114
+
Have a bug or a feature request? Please [open a Github issue](https://github.com/plotly/plotly.js/issues/new) keeping in mind the [issue guidelines](https://github.com/plotly/plotly.js/blob/master/.github/ISSUE_TEMPLATE.md). You may also want to read about [how changes get made to Plotly.js](https://github.com/plotly/plotly.js/blob/master/CONTRIBUTING.md)
156
115
157
-
* Follow [@plotlygraphs](https://twitter.com/plotlygraphs) on Twitter for the latest Plotly news.
158
-
* Implementation help may be found on community.plot.com (tagged [`plotly-js`](https://community.plotly.com/c/plotly-js)) or
159
-
on Stack Overflow (tagged [`plotly`](https://stackoverflow.com/questions/tagged/plotly)).
160
-
* Developers should use the keyword `plotly` on packages which modify or add to the functionality of plotly.js when distributing through [npm](https://www.npmjs.com/browse/keyword/plotly).
161
116
162
117
---
163
-
## Versioning
164
-
165
-
This project is maintained under the [Semantic Versioning guidelines](https://semver.org/).
118
+
## Contributing
166
119
167
-
See the [Releases section](https://github.com/plotly/plotly.js/releases) of our GitHub project for changelogs for each release version of plotly.js.
120
+
Please read through our [contributing guidelines](https://github.com/plotly/plotly.js/blob/master/CONTRIBUTING.md). Included are directions for opening issues, using plotly.js in your project and notes on development.
168
121
169
122
---
170
123
## Notable contributors
@@ -197,3 +150,17 @@ Plotly.js is at the core of a large and dynamic ecosystem with many contributors
197
150
Code and documentation copyright 2021 Plotly, Inc.
198
151
199
152
Code released under the [MIT license](https://github.com/plotly/plotly.js/blob/master/LICENSE).
153
+
154
+
### Versioning
155
+
156
+
This project is maintained under the [Semantic Versioning guidelines](https://semver.org/).
157
+
158
+
See the [Releases section](https://github.com/plotly/plotly.js/releases) of our GitHub project for changelogs for each release version of plotly.js.
159
+
160
+
---
161
+
## Community
162
+
163
+
* Follow [@plotlygraphs](https://twitter.com/plotlygraphs) on Twitter for the latest Plotly news.
164
+
* Implementation help may be found on community.plot.com (tagged [`plotly-js`](https://community.plotly.com/c/plotly-js)) or
165
+
on Stack Overflow (tagged [`plotly`](https://stackoverflow.com/questions/tagged/plotly)).
166
+
* Developers should use the keyword `plotly` on packages which modify or add to the functionality of plotly.js when distributing through [npm](https://www.npmjs.com/browse/keyword/plotly).
0 commit comments