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
+60-17Lines changed: 60 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -1,25 +1,30 @@
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 and use it in this component, 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.
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.
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 version](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,
**Note**: 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).
32
67
33
68
## API
34
69
@@ -42,12 +77,14 @@ The only requirement is that plotly.js is loaded before you inject it. You may n
42
77
|`frames`|`Array`|`undefined`| list of frame objects |
43
78
|`fit`|`Boolean`|`false`| When true, disregards `layout.width` and `layout.height` and fits to the parent div size, updating on `window.resize`|
44
79
|`debug`|`Boolean`|`false`| Assign the graph div to `window.gd` for debugging |
45
-
| `onInitialized |`Function`|null| Callback executed once after plot is initialized |
46
-
| `onUpdate |`Function`|null| Callback executed when a plotly.js API method is invoked |
47
-
| `onError |`Function`|null| Callback executed when a plotly.js API method rejects |
80
+
|`onInitialized`|`Function`|`undefined`| Callback executed once after plot is initialized |
81
+
|`onUpdate`|`Function`|`undefined`| Callback executed when a plotly.js API method is invoked |
82
+
|`onError`|`Function`|`undefined`| Callback executed when a plotly.js API method rejects |
48
83
49
84
### Event handler props
50
85
86
+
Event handlers for [`plotly.js` events](https://plot.ly/javascript/plotlyjs-events/) may be attached through the following props.
87
+
51
88
| Prop | Type | Plotly Event |
52
89
| ---- | ---- | ----------- |
53
90
|`onAfterExport`|`Function`|`plotly_afterexport`|
@@ -76,6 +113,10 @@ The only requirement is that plotly.js is loaded before you inject it. You may n
This component currently creates a new plot every time the input changes. That makes it stable and good enough for production use, but `plotly.js` will soon gain react-style support for computing and drawing changes incrementally. What does that mean for you? That means you can expect to keep using this component with little or no modification but that the plotting will simply happen much faster when you upgrade to the first version of `plotly.js` to support this feature. If this component requires any significant changes, a new major version will be released at the same time to ensure stability.
119
+
79
120
## Development
80
121
81
122
To get started:
@@ -85,15 +126,17 @@ $ npm install
85
126
$ npm start
86
127
```
87
128
88
-
To build the dist version:
129
+
To transpile from ES2015 + JSX into the ES5 npm-distributed version:
0 commit comments