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
You may also consider using [`plotly.js-dist`](https://www.npmjs.com/package/plotly.js-dist) if you prefer using an unminified package.
49
+
49
50
---
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>.
51
+
## Load via script tag
52
+
53
+
### The script HTML element
54
+
> In the examples below `Plotly` object is added to the window scope by `script`. 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).
@@ -59,22 +61,23 @@ Fastly supports Plotly.js with free CDN service. Read more at <https://www.fastl
59
61
<divid="gd"></div>
60
62
61
63
<script>
62
-
Plotly.newPlot("gd", {
63
-
"data": [{
64
-
"y": [1, 2, 3]
65
-
}],
66
-
"layout": {
67
-
"width":600,
68
-
"height":400
69
-
}
70
-
});
64
+
Plotly.newPlot("gd", /* JSON object */ {
65
+
"data": [{ "y": [1, 2, 3] }],
66
+
"layout": { "width":600, "height":400}
67
+
})
71
68
</script>
72
69
</body>
73
70
```
74
-
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).
71
+
72
+
Alternatively you may consider using [native ES6 import](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) in the script tag.
Fastly supports Plotly.js with free CDN service. Read more at <https://www.fastly.com/open-source>.
78
81
79
82
### Un-minified versions are also available on CDN
80
83
While non-minified source files may contain characters outside UTF-8, it is recommended that you specify the `charset` when loading those bundles.
@@ -84,11 +87,9 @@ While non-minified source files may contain characters outside UTF-8, it is reco
84
87
85
88
> 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.
86
89
87
-
### To support MathJax
88
-
Load relevant MathJax (v2) files *Before* the plotly.js script tag:
90
+
To support MathJax, you need to load version two of MathJax e.g. `v2.7.5` files from CDN or npm.
@@ -97,8 +98,8 @@ There are two kinds of plotly.js bundles:
97
98
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.
98
99
99
100
---
100
-
## Alternative ways to require or build plotly.js
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).
101
+
## Alternative ways to load and build plotly.js
102
+
If your library needs to bundle or directly load[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).
102
103
103
104
---
104
105
## Documentation
@@ -113,7 +114,6 @@ For more info about contributing to Plotly documentation, please read through [c
113
114
114
115
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