8000 Merge pull request #202 from plotly/updates-2020 · plotly/react-plotly.js@ed21137 · GitHub
[go: up one dir, main page]

Skip to content
< 8000 header class="HeaderMktg header-logged-out js-details-container js-header Details f4 py-3" role="banner" data-is-top="true" data-color-mode=light data-light-theme=light data-dark-theme=dark>

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

Appearance settings

Commit ed21137

Browse files
authored
Merge pull request #202 from plotly/updates-2020
Updates 2020
2 parents b274f6b + 0dc5179 commit ed21137

File tree

6 files changed

+68
-66
lines changed

6 files changed

+68
-66
lines changed

.circleci/config.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ version: 2.0
33
jobs:
44
build:
55
docker:
6-
- image: circleci/node:10.9.0
6+
- image: circleci/node:12.18.3
77
working_directory: ~/react-plotly.js
88
steps:
99
- checkout
1010
- restore_cache:
1111
keys:
12-
- v{{ .Environment.CIRCLE_CACHE_VERSION }}-deps-{{ .Branch }}-{{ checksum "package-lock.json" }}
13-
- v{{ .Environment.CIRCLE_CACHE_VERSION }}-deps-master-{{ checksum "package-lock.json" }}
12+
- v{{ .Environment.CIRCLE_CACHE_VERSION }}-deps-{{ .Branch }}-{{ checksum "package.json" }}
13+
- v{{ .Environment.CIRCLE_CACHE_VERSION }}-deps-master-{{ checksum "package.json" }}
1414
- run:
1515
name: Install dependencies
1616
command: |
@@ -32,7 +32,7 @@ jobs:
3232

3333
test:
3434
docker:
35-
- image: circleci/node:10.9.0
35+
- image: circleci/node:12.18.3
3636
working_directory: ~/react-plotly.js
3737
steps:
3838
- checkout

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ Event handlers for specific [`plotly.js` events](https://plot.ly/javascript/plot
167167
| `onLegendClick` | `Function` | `plotly_legendclick` |
168168
| `onLegendDoubleClick` | `Function` | `plotly_legenddoubleclick` |
169169
| `onRelayout` | `Function` | `plotly_relayout` |
170+
| `onRelayouting` | `Function` | `plotly_relayouting` |
170171
| `onRestyle` | `Function` | `plotly_restyle` |
171172
| `onRedraw` | `Function` | `plotly_redraw` |
172173
| `onSelected` | `Function` | `plotly_selected` |
@@ -243,4 +244,4 @@ $ npm run test
243244

244245
## License
245246

246-
&copy; 2017 Plotly, Inc. MIT License.
247+
&copy; 2017-2020 Plotly, Inc. MIT License.

package.json

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-plotly.js",
3-
"version": "2.4.0",
3+
"version": "2.5.0",
44
"license": "MIT",
55
"description": "A plotly.js react component from Plotly",
66
"author": "Plotly, Inc.",
@@ -21,7 +21,7 @@
2121
"test": "npm run lint && npm run deps && jest",
2222
"watch-test": "jest --watch",
2323
"watch": "nodemon --exec \"npm run make:lib\" -w src",
24-
"deps": "./node_modules/.bin/dependency-check package.json --entry src/react-plotly.js --missing"
24+
"deps": "./node_modules/.bin/dependency-check src/react-plotly.js --missing"
2525
},
2626
"keywords": [
2727
"graphing",
@@ -31,48 +31,48 @@
3131
"plotly",
3232
"react"
3333
],
34+
"dependencies": {
35+
"prop-types": "^15.7.2"
36+
},
3437
"devDependencies": {
35-
"@babel/cli": "^7.2.3",
36-
"@babel/core": "^7.3.3",
37-
"@babel/plugin-proposal-class-properties": "^7.3.3",
38-
"@babel/preset-env": "^7.3.1",
39-
"@babel/preset-react": "^7.0.0",
40-
"babel-eslint": "^10.0.1",
38+
"@babel/cli": "^7.11.6",
39+
"@babel/core": "^7.11.6",
40+
"@babel/plugin-proposal-class-properties": "^7.10.4",
41+
"@babel/preset-env": "^7.11.5",
42+
"@babel/preset-react": "^7.10.4",
43+
"babel-eslint": "^10.1.0",
4144
"babelify": "^10.0.0",
4245
"brfs": "^2.0.2",
43-
"browserify": "^16.2.3",
46+
"browserify": "^16.5.2",
4447
"browserify-global-shim": "^1.0.3",
4548
"cash-mv": "^0.2.0",
46-
"dependency-check": "^3.3.0",
47-
"enzyme": "^3.9.0",
48-
"enzyme-adapter-react-16": "^1.9.1",
49-
"eslint": "^5.14.1",
50-
"eslint-config-prettier": "^4.0.0",
51-
"eslint-plugin-import": "^2.16.0",
52-
"eslint-plugin-react": "^7.12.4",
49+
"dependency-check": "^4.1.0",
50+
"enzyme": "^3.11.0",
51+
"enzyme-adapter-react-16": "^1.15.4",
52+
"eslint": "^7.9.0",
53+
"eslint-config-prettier": "^6.11.0",
54+
"eslint-plugin-import": "^2.22.0",
55+
"eslint-plugin-react": "^7.20.6",
5356
"event-emitter": "^0.3.5",
54-
"jest": "^24.1.0",
55-
"mkdirp": "^0.5.1",
56-
"nodemon": "^1.18.10",
57-
"onetime": "^3.0.0",
57+
"jest": "^26.4.2",
58+
"mkdirp": "^1.0.4",
59+
"nodemon": "^2.0.4",
60+
"onetime": "^5.1.2",
5861
"plotly.js": "^1.35.0",
59-
"prettier": "^1.16.4",
60-
"react": "^16.8.2",
62+
"prettier": "^2.1.1",
63+
"react": "^16.13.1",
6164
"react-addons-test-utils": "^15.6.0",
62-
"react-dom": "^16.8.2",
63-
"react-test-renderer": "^16.8.2",
64-
"rimraf": "^2.6.2",
65-
"semver": "^5.4.1",
66-
"uglify-js": "^3.0.26"
65+
"react-dom": "^16.13.1",
66+
"react-test-renderer": "^16.13.1",
67+
"rimraf": "^3.0.2",
68+
"semver": "^7.3.2",
69+
"uglify-js": "^3.10.4"
6770
},
6871
"peerDependencies": {
6972
"plotly.js": ">1.34.0",
7073
"react": ">0.13.0"
7174
},
7275
"browserify-global-shim": {
7376
"react": "React"
74-
},
75-
"dependencies": {
76-
"prop-types": "^15.7.2"
7777
}
7878
}

src/__mocks__/plotly.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,35 @@ const state = {};
44
const ASYNC_DELAY = 1;
55

66
export default {
7-
plot: jest.fn(gd => {
7+
plot: jest.fn((gd) => {
88
state.gd = gd;
99
setTimeout(() => {
1010
state.gd.emit('plotly_afterplot');
1111
}, ASYNC_DELAY);
1212
}),
13-
newPlot: jest.fn(gd => {
13+
newPlot: jest.fn((gd) => {
1414
state.gd = gd;
1515
EventEmitter(state.gd); // eslint-disable-line new-cap
1616

1717
setTimeout(() => {
1818
state.gd.emit('plotly_afterplot');
1919
}, ASYNC_DELAY);
2020
}),
21-
react: jest.fn(gd => {
21+
react: jest.fn((gd) => {
2222
state.gd = gd;
2323
EventEmitter(state.gd); // eslint-disable-line new-cap
2424

2525
setTimeout(() => {
2626
state.gd.emit('plotly_afterplot');
2727
}, ASYNC_DELAY);
2828
}),
29-
relayout: jest.fn(gd => {
29+
relayout: jest.fn((gd) => {
3030
state.gd = gd;
3131
setTimeout(() => {
3232
state.gd.emit('plotly_relayout');
3333
}, ASYNC_DELAY);
3434
}),
35-
restyle: jest.fn(gd => {
35+
restyle: jest.fn((gd) => {
3636
state.gd = gd;
3737
setTimeout(() => {
3838
state.gd.emit('plotly_restyle');

src/__tests__/react-plotly.test.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('<Plotly/>', () => {
3333

3434
describe('with mocked plotly.js', () => {
3535
beforeEach(() => {
36-
Plotly = require.requireMock('../__mocks__/plotly.js').default;
36+
Plotly = jest.requireMock('../__mocks__/plotly.js').default;
3737
PlotComponent = createComponent(Plotly);
3838

3939
// Override the parent element size:
@@ -43,19 +43,19 @@ describe('<Plotly/>', () => {
4343
});
4444
});
4545

46-
describe('initialization', function() {
47-
test('calls Plotly.react on instantiation', done => {
46+
describe('initialization', function () {
47+
test('calls Plotly.react on instantiation', (done) => {
4848
createPlot({})
4949
.then(() => {
5050
expect(Plotly.react).toHaveBeenCalled();
5151
})
52-
.catch(err => {
52+
.catch((err) => {
5353
done.fail(err);
5454
})
5555
.then(done);
5656
});
5757

58-
test('passes data', done => {
58+
test('passes data', (done) => {
5959
createPlot({
6060
data: [{x: [1, 2, 3]}],
6161
layout: {title: 'foo'},
@@ -66,11 +66,11 @@ describe('<Plotly/>', () => {
6666
layout: {title: 'foo'},
6767
});
6868
})
69-
.catch(err => done.fail(err))
69+
.catch((err) => done.fail(err))
7070
.then(done);
7171
});
7272

73-
test('accepts width and height', done => {
73+
test('accepts width and height', (done) => {
7474
createPlot({
7575
layout: {width: 320, height: 240},
7676
})
@@ -79,13 +79,13 @@ describe('<Plotly/>', () => {
7979
layout: {width: 320, height: 240},
8080
});
8181
})
82-
.catch(err => done.fail(err))
82+
.catch((err) => done.fail(err))
8383
.then(done);
8484
});
8585
});
8686

8787
describe('plot updates', () => {
88-
test('updates data', done => {
88+
test('updates data', (done) => {
8989
createPlot({
9090
layout: {width: 123, height: 456},
9191
onUpdate: once(() => {
@@ -96,13 +96,13 @@ describe('<Plotly/>', () => {
9696
done();
9797
}),
9898
})
99-
.then(plot => {
99+
.then((plot) => {
100100
plot.setProps({data: [{x: [1, 2, 3]}]});
101101
})
102-
.catch(err => done.fail(err));
102+
.catch((err) => done.fail(err));
103103
});
104104

105-
test('updates data when revision is defined but not changed', done => {
105+
test('updates data when revision is defined but not changed', (done) => {
106106
createPlot({
107107
revision: 1,
108108
layout: {width: 123, height: 456},
@@ -114,13 +114,13 @@ describe('<Plotly/>', () => {
114114
done();
115115
}),
116116
})
117-
.then(plot => {
117+
.then((plot) => {
118118
plot.setProps({revision: 1, data: [{x: [1, 2, 3]}]});
119119
})
120-
.catch(err => done.fail(err));
120+
.catch((err) => done.fail(err));
121121
});
122122

123-
test('sets the title', done => {
123+
test('sets the title', (done) => {
124124
createPlot({
125125
onUpdate: once(() => {
126126
expectPlotlyAPICall(Plotly.react, {
@@ -129,13 +129,13 @@ describe('<Plotly/>', () => {
129129
done();
130130
}),
131131
})
132-
.then(plot => {
132+
.then((plot) => {
133133
plot.setProps({layout: {title: 'test test'}});
134134
})
135-
.catch(err => done.fail(err));
135+
.catch((err) => done.fail(err));
136136
});
137137

138-
test('revision counter', done => {
138+
test('revision counter', (done) => {
139139
var callCnt = 0;
140140
createPlot({
141141
revision: 0,
@@ -153,15 +153,15 @@ describe('<Plotly/>', () => {
153153
}
154154
},
155155
})
156-
.then(plot => {
156+
.then((plot) => {
157157
// Update with and without revision bumps:
158158
/* eslint-disable no-magic-numbers */
159159
setTimeout(() => plot.setProps({layout: {title: 'test test'}}), 10);
160160
setTimeout(() => plot.setProps({revision: 1, layout: {title: 'test test'}}), 20);
161161
setTimeout(() => plot.setProps({revision: 1, layout: {title: 'test test'}}), 30);
162162
setTimeout(() => plot.setProps({revision: 2, layout: {title: 'test test'}}), 40);
163163
})
164-
.catch(err => done.fail(err));
164+
.catch((err) => done.fail(err));
165165
});
166166
});
167167

@@ -170,7 +170,7 @@ describe('<Plotly/>', () => {
170170
const onRelayout = () => {};
171171

172172
createPlot({onRelayout}).then((plot) => {
173-
const { handlers } = plot.instance();
173+
const {handlers} = plot.instance();
174174

175175
expect(plot.prop('onRelayout')).toBe(onRelayout);
176176
expect(handlers.Relayout).toBe(onRelayout);

src/factory.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const updateEvents = [
4343
'plotly_relayouting',
4444
'plotly_doubleclick',
4545
'plotly_animated',
46+
'plotly_sunburstclick',
4647
];
4748

4849
// Check if a window is available since SSR (server-side rendering)
@@ -95,7 +96,7 @@ export default function plotComponentFactory(Plotly) {
9596
this.attachUpdateEvents();
9697
}
9798
})
98-
.catch(err => {
99+
.catch((err) => {
99100
if (this.props.onError) {
100101
this.props.onError(err);
101102
}
@@ -153,7 +154,7 @@ export default function plotComponentFactory(Plotly) {
153154
return;
154155
}
155156

156-
updateEvents.forEach(updateEvent => {
157+
updateEvents.forEach((updateEvent) => {
157158
this.el.on(updateEvent, this.handleUpdate);
158159
});
159160
}
@@ -163,7 +164,7 @@ export default function plotComponentFactory(Plotly) {
163164
return;
164165
}
165166

166-
updateEvents.forEach(updateEvent => {
167+
updateEvents.forEach((updateEvent) => {
167168
this.el.removeListener(updateEvent, this.handleUpdate);
168169
});
169170
}
@@ -208,7 +209,7 @@ export default function plotComponentFactory(Plotly) {
208209

209210
// Attach and remove event handlers as they're added or removed from props:
210211
syncEventHandlers() {
211-
eventNames.forEach(eventName => {
212+
eventNames.forEach((eventName) => {
212213
const prop = this.props['on' + eventName];
213214
const handler = this.handlers[eventName];
214215
const hasHandler = Boolean(handler);
@@ -269,7 +270,7 @@ export default function plotComponentFactory(Plotly) {
269270
divId: PropTypes.string,
270271
};
271272

272-
eventNames.forEach(eventName => {
273+
eventNames.forEach((eventName) => {
273274
PlotlyComponent.propTypes['on' + eventName] = PropTypes.func;
274275
});
275276

0 commit comments

Comments
 (0)
0