Table of contents
Load as a node module
- ``` shell
- npm i --save plotly.js-dist-min
- ```
- ``` js
- // ES6 module
- import Plotly from 'plotly.js-dist-min'
- // CommonJS
- var Plotly = require('plotly.js-dist-min')
- ```
Load via script tag
The script HTML element
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 syntax is enough to get started i.e. with/without JavaScript! To learn and build more with plotly.js please visit plotly.js documentation.
- ``` html
- <head>
- <script src="https://cdn.plot.ly/plotly-2.20.0.min.js" charset="utf-8"></script>
- </head>
- <body>
- <div id="gd"></div>
- <script>
- Plotly.newPlot("gd", /* JSON object */ {
- "data": [{ "y": [1, 2, 3] }],
- "layout": { "width": 600, "height": 400}
- })
- </script>
- </body>
- ```
- ``` html
- <script type="module">
- import "https://cdn.plot.ly/plotly-2.20.0.min.js"
- Plotly.newPlot("gd", [{ y: [1, 2, 3] }])
- </script>
- ```
Un-minified versions are also available on CDN
- ``` html
- <script src="https://cdn.plot.ly/plotly-2.20.0.js" charset="utf-8"></script>
- ```
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.5. Therefore, to use the CDN with plotly.js v2 and higher, you must specify an exact plotly.js version.
MathJax
- ``` html
- <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_SVG.js"></script>
- ```
- ``` html
- <script src="https://cdn.jsdelivr.net/npm/mathjax@3.2.2/es5/tex-svg.js"></script>
- ```
When using MathJax version 3, it is also possible to use chtml output on the other parts of the page in addition to svg output for the plotly graph. Please refer to devtools/test_dashboard/index-mathjax3chtml.html to see an example.
Bundles
Alternative ways to load and build plotly.js
Documentation
Bugs and feature requests
Contributing
Notable contributors
| GitHub | Status | |
|---|---|---|
| :--- | :--- | :--- |
| Alex C. Johnson | @alexcjohnson | |
| Mojtaba Samimi | @archmoj | @solarchvision |
| Antoine Roy-Gobeil | @antoinerg | |
| Nicolas Kruchten | @nicolaskruchten | @nicolaskruchten |
| Jon Mease | @jonmmease | @jonmmease |
| Étienne Tétreault-Pinard | @etpinard | @etpinard |
| Mikola Lysenko | @mikolalysenko | @MikolaLysenko |
| Ricky Reusser | @rreusser | @rickyreusser |
| Dmitry Yv. | @dy | @DimaYv |
| Robert Monfera | @monfera | @monfera |
| Robert Möstl | @rmoestl | @rmoestl |
| Nicolas Riesco | @n-riesco | |
| Miklós Tusz | @mdtusz | @mdtusz |
| Chelsea Douglas | @cldougl | |
| Ben Postlethwaite | @bpostlethwaite | |
| Chris Parmer | @chriddyp | |
| Alex Vados | @alexander-daniel |