Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Initial version #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
rreusser merged 21 commits into master from develop
Oct 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
1005beb
Fix tests and set up eslint
rreusser Oct 5, 2017
9463915
Clean up module details
rreusser Oct 5, 2017
0f7e254
Rebuild
rreusser Oct 5, 2017
c6f3fed
Add readme documentation
rreusser Oct 5, 2017
bc28b49
Fix directory structure
rreusser Oct 5, 2017
469744f
Fix the example
rreusser Oct 5, 2017
60d392f
Fix build script
rreusser Oct 5, 2017
8af5a46
Remove unused scripts
rreusser Oct 5, 2017
7140f71
Fix a readme typo
rreusser Oct 5, 2017
1b13171
Highlight note
rreusser Oct 5, 2017
895e26c
Be more precise about default callback values
rreusser Oct 5, 2017
7b1a583
Add note on roadmap
rreusser Oct 5, 2017
a8544ad
Remove src/*.map files
rreusser Oct 5, 2017
867eec9
Improve readme clarity
rreusser Oct 5, 2017
726c943
Rebuild build/
rreusser Oct 5, 2017
86a13da
Remove build entirely; I don't think anyone uses it.
rreusser Oct 5, 2017
843ce53
Fix readme to reflect build process
rreusser Oct 5, 2017
3e820e8
Remove netlify deploy script
rreusser Oct 5, 2017
dd455b4
Commit build files
rreusser Oct 6, 2017
05a3a68
Hook up revision logic for shouldComponentUpdate
rreusser Oct 11, 2017
974e971
Refactor onInitialize handler
rreusser Oct 11, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .eslintrc
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"rules": {
"semi": 2,
"no-unused-vars": 2,
"react/display-name": 2,
"react/jsx-key": 2,
"react/jsx-no-comment-textnodes": 2,
"react/jsx-no-duplicate-props": 2,
"react/jsx-no-target-blank": 2,
"react/jsx-no-undef": 2,
"react/jsx-uses-react": 2,
"react/jsx-uses-vars": 2,
"react/no-children-prop": 2,
"react/no-danger-with-children": 2,
"react/no-deprecated": 2,
"react/no-direct-mutation-state": 2,
"react/no-find-dom-node": 2,
"react/no-is-mounted": 2,
"react/no-render-return-value": 2,
"react/no-string-refs": 2,
"react/no-unescaped-entities": 2,
"react/no-unknown-property": 2,
"react/prop-types": 2,
"react/react-in-jsx-scope": 2,
"react/require-render-return": 2,
},
"plugins": [
"react"
]
}
21 changes: 21 additions & 0 deletions LICENSE
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2017 Plotly, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
77 changes: 60 additions & 17 deletions README.md
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
# plotly.js-react
# react-plotly.js

> A React component for plotly.js charts <a href="https://z8tgespzmd63w51brzdh360ryvgt3m1ho.netlify.com/">&rarr; See demo</a>
> A [plotly.js](https://github.com/plotly/plotly.js) React component from [Plotly](https://plot.ly/)

## Installation

Not yet published

```bash
$ npm install plotly.js-react
$ npm install react-plotly.js plotly.js
```

## Usage

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).
### With bundled `plotly.js`

[`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.

```bash
$ npm install -S react-plotly.js plotly.js
```

Since `plotly.js` is a peer dependency, you do not need to require it separately to use it.

```javascript
const createPlotlyComponent = require('plotly.js-react');
const PlotlyComponent = createPlotlyComponent(Plotly);
import Plot from 'react-plotly.js'

render () {
<PlotlyComponent
return <Plot
data={...}
layout={...}
frames={...}
Expand All @@ -28,7 +33,37 @@ render () {
}
```

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.
### With external `plotly.js`

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.

```bash
$ npm install -S react-plotly.js
```

Given perhaps a script tag that has loaded a CDN version of plotly.js,

```html
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
```

you may then inject Plotly and use the returned React component:

```javascript
import plotComponentFactory from 'react-plotly.js/factory'
const Plot = plotComponentFactory(Plotly);

render () {
return <Plot
data={...}
layout={...}
frames={...}
config={...}
/>
}
```

**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).

## API

Expand All @@ -42,12 +77,14 @@ The only requirement is that plotly.js is loaded before you inject it. You may n
| `frames` | `Array` | `undefined` | list of frame objects |
| `fit` | `Boolean` | `false` | When true, disregards `layout.width` and `layout.height` and fits to the parent div size, updating on `window.resize` |
| `debug` | `Boolean` | `false` | Assign the graph div to `window.gd` for debugging |
| `onInitialized | `Function` | null | Callback executed once after plot is initialized |
| `onUpdate | `Function` | null | Callback executed when a plotly.js API method is invoked |
| `onError | `Function` | null | Callback executed when a plotly.js API method rejects |
| `onInitialized` | `Function` | `undefined` | Callback executed once after plot is initialized |
| `onUpdate` | `Function` | `undefined` | Callback executed when a plotly.js API method is invoked |
| `onError` | `Function` | `undefined` | Callback executed when a plotly.js API method rejects |

### Event handler props

Event handlers for [`plotly.js` events](https://plot.ly/javascript/plotlyjs-events/) may be attached through the following props.

| Prop | Type | Plotly Event |
| ---- | ---- | ----------- |
| `onAfterExport` | `Function` | `plotly_afterexport` |
Expand Down Expand Up @@ -76,6 +113,10 @@ The only requirement is that plotly.js is loaded before you inject it. You may n
| `onTransitionInterrupted` | `Function` | `plotly_transitioninterrupted` |
| `onUnhover` | `Function` | `plotly_unhover` |

## Roadmap

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.

## Development

To get started:
Expand All @@ -85,15 +126,17 @@ $ npm install
$ npm start
```

To build the dist version:
To transpile from ES2015 + JSX into the ES5 npm-distributed version:

```bash
$ npm run prepublish
$ npm run prepublishOnly
```

## See also
To run the tests:

- [plotly-react-editor](https://github.com/plotly/plotly-react-editor)
```bash
$ npm run test
```

## License

Expand Down
Loading

AltStyle によって変換されたページ (->オリジナル) /