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
+53-13
Original file line number
Diff line number
Diff line change
@@ -1,25 +1,60 @@
1
-
# plotly.js-react
1
+
# react-plotly.js
2
2
3
-
> A React component for plotly.js charts <ahref="https://z8tgespzmd63w51brzdh360ryvgt3m1ho.netlify.com/">→ See demo</a>
3
+
> A [plotly.js](https://github.com/plotly/plotly.js) react component from [Plotly](https://plot.ly/)
4
4
5
5
## Installation
6
6
7
-
Not yet published
8
-
9
7
```bash
10
-
$ npm install plotly.js-react
8
+
$ npm install react-plotly.js plotly.js
11
9
```
12
10
13
11
## Usage
14
12
15
-
The component definition is created by dependency injection so that you can use whichever version of plotly.js you'd like, including the [CDN versions](https://plot.ly/javascript/getting-started/#plotlyjs-cdn).
13
+
### With bundled `plotly.js`
14
+
15
+
[`plotly.js`](https://github.com/plotly/plotly.js) is a peer dependency of `react-plotly.js`. If you would like to bundle `plotly.js` with the rest of your project, you must install it separately.
16
+
17
+
```bash
18
+
$ npm install -S react-plotly.js plotly.js
19
+
```
20
+
21
+
Since `plotly.js` is a peer dependency, you do not need to require it separately to use it.
22
+
23
+
```javascript
24
+
importPlotfrom'react-plotly.js'
25
+
26
+
render () {
27
+
return<Plot
28
+
data={...}
29
+
layout={...}
30
+
frames={...}
31
+
config={...}
32
+
/>
33
+
}
34
+
```
35
+
36
+
### With external `plotly.js`
37
+
38
+
If you wish to use a version of `plotly.js` that is not bundled with the rest of your project, whether a [CDN versions](https://plot.ly/javascript/getting-started/#plotlyjs-cdn) or through a [static distribution bundle](https://github.com/plotly/plotly.js/tree/master/dist), you may skip installing `plotly.js` and ignore the peer dependency warning.
39
+
40
+
```bash
41
+
$ npm install -S react-plotly.js
42
+
```
43
+
44
+
Given perhaps a script tag that has loaded a CDN version of plotly.js,
The only requirement is that plotly.js is loaded before you inject it. You may need to use a module like [load-script](https://www.npmjs.com/package/load-script) to ensure it's available.
66
+
You must ensure `Plotly` is available before your React app tries to render the component. That could mean perhaps using script tag (without `async` or `defer`) or a utility like [load-script](https://www.npmjs.com/package/load-script).
67
+
32
68
33
69
## API
34
70
@@ -48,6 +84,8 @@ The only requirement is that plotly.js is loaded before you inject it. You may n
48
84
49
85
### Event handler props
50
86
87
+
Event handlers for [`plotly.js` events](https://plot.ly/javascript/plotlyjs-events/) may be attached through the following props.
0 commit comments