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
+41-29Lines changed: 41 additions & 29 deletions
Original file line number
Diff line number
Diff line change
@@ -18,8 +18,8 @@ Plotly.js can be used to produce dozens of chart types and visualizations, inclu
18
18
19
19
## Table of contents
20
20
21
-
*[Load from npm (Node.js Package Manager)](#load-from-npm-nodejs-package-manager)
22
-
*[Load from Content Delivery Network (CDN)](#load-from-content-delivery-network-cdn)
21
+
*[Load via node.js](#load-via-nodejs)
22
+
*[Load via script tag](#load-via-script-tag)
23
23
*[Bundles](#bundles)
24
24
*[Alternative ways to require or build plotly.js](#alternative-ways-to-require-or-build-plotlyjs)
25
25
*[Documentation](#documentation)
@@ -30,27 +30,31 @@ Plotly.js can be used to produce dozens of chart types and visualizations, inclu
30
30
*[Community](#community)
31
31
32
32
---
33
-
## Load from npm (Node.js Package Manager)
34
-
33
+
## Load via node.js
34
+
install plotly.js source
35
35
```sh
36
-
npm install plotly.js-dist-min
36
+
npm i --save plotly.js
37
37
```
38
-
39
-
and import plotly.js as
40
-
41
-
```js
42
-
importPlotlyfrom'plotly.js-dist-min'
38
+
Or [a ready-to-use distributed bundle](https://github.com/plotly/plotly.js/blob/master/dist/README.md)
39
+
```sh
40
+
npm i --save plotly.js-dist-min
43
41
```
44
-
Or
42
+
43
+
and use import or require in node.js
45
44
```js
46
-
var Plotly =require('plotly.js-dist-min')
45
+
// ES6 module
46
+
importPlotlyfrom'plotly.js-dist-dist';
47
+
48
+
// CommonJS
49
+
var Plotly =require('plotly.js-dist-dist');
47
50
```
48
51
49
52
---
50
-
## Load from Content Delivery Network (CDN)
51
-
Fastly supports Plotly.js with free CDN service. Read more at <https://www.fastly.com/open-source>.
53
+
## Load via script tag
54
+
55
+
### The script HTML element
56
+
> In the examples below `Plotly` object is added to the window scope by `script` and `import`. The `newPlot` method is then used to draw an interactive figure as described by `data` and `layout` into the desired `div` here named `gd`. 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! To learn and build more with plotly.js please visit [plotly.js documentation](https://plotly.com/javascript).
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).
89
+
90
+
To learn more about native imports please visit [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules). Also please note that ES6 import is not supported by IE-11.
78
91
79
92
### Un-minified versions are also available on CDN
80
93
While non-minified source files may contain characters outside UTF-8, it is recommended that you specify the `charset` when loading those bundles.
@@ -113,7 +126,6 @@ For more info about contributing to Plotly documentation, please read through [c
113
126
114
127
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)
0 commit comments