Skip to content

Commit 9b30fea

Browse files
authored
Merge pull request #5420 from plotly/simplify-Fx-and-Plots-APIs
Drop various methods from Plotly.Fx and Plotly.Plots in the API
2 parents 83f105d + 911b145 commit 9b30fea

File tree

7 files changed

+27
-13
lines changed

7 files changed

+27
-13
lines changed

src/core.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,20 @@ if(window.PlotlyLocales && Array.isArray(window.PlotlyLocales)) {
7474
exports.Icons = require('./fonts/ploticon');
7575

7676
// unofficial 'beta' plot methods, use at your own risk
77-
exports.Plots = require('./plots/plots');
78-
exports.Fx = require('./components/fx');
77+
var Fx = require('./components/fx');
78+
var Plots = require('./plots/plots');
79+
80+
exports.Plots = {
81+
resize: Plots.resize,
82+
graphJson: Plots.graphJson,
83+
sendDataToCloud: Plots.sendDataToCloud
84+
};
85+
exports.Fx = {
86+
hover: Fx.hover,
87+
unhover: Fx.unhover,
88+
loneHover: Fx.loneHover,
89+
loneUnhover: Fx.loneUnhover
90+
};
7991
exports.Snapshot = require('./snapshot');
8092
exports.PlotSchema = require('./plot_api/plot_schema');
8193
exports.Queue = require('./lib/queue');

test/jasmine/bundle_tests/finance_test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
var Plots = require('@src/plots/plots');
12
var Plotly = require('@lib/core');
23
var ohlc = require('@lib/ohlc');
34
var candlestick = require('@lib/candlestick');
@@ -14,13 +15,13 @@ describe('Bundle with finance trace type', function() {
1415
var mock = require('@mocks/finance_style.json');
1516

1617
it('should not register transforms anymore', function() {
17-
var transformModules = Object.keys(Plotly.Plots.transformsRegistry);
18+
var transformModules = Object.keys(Plots.transformsRegistry);
1819

1920
expect(transformModules).toEqual([]);
2021
});
2122

2223
it('should register the correct trace modules for the generated traces', function() {
23-
var traceModules = Object.keys(Plotly.Plots.modules);
24+
var traceModules = Object.keys(Plots.modules);
2425

2526
// scatter is registered no matter what
2627
// ohlc uses some parts of box by direct require but does not need to register it.

test/jasmine/tests/animate_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var Plotly = require('@lib/index');
22
var Lib = require('@src/lib');
33
var Registry = require('@src/registry');
4-
var Plots = Plotly.Plots;
4+
var Plots = require('@src/plots/plots');
55

66
var d3Select = require('../../strict-d3').select;
77
var d3SelectAll = require('../../strict-d3').selectAll;

test/jasmine/tests/click_test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var Plotly = require('@lib/index');
2+
var Plots = require('@src/plots/plots');
23
var Lib = require('@src/lib');
34
var Drawing = require('@src/components/drawing');
45
var DBLCLICKDELAY = require('@src/plot_api/plot_config').dfltConfig.doubleClickDelay;
@@ -50,7 +51,7 @@ describe('Test click interactions:', function() {
5051

5152
function doubleClick(x, y) {
5253
return doubleClickRaw(x, y).then(function() {
53-
return Plotly.Plots.previousPromises(gd);
54+
return Plots.previousPromises(gd);
5455
});
5556
}
5657

test/jasmine/tests/command_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var Plotly = require('@lib/index');
22
var Registry = require('@src/registry');
3-
var Plots = Plotly.Plots;
3+
var Plots = require('@src/plots/plots');
44
var createGraphDiv = require('../assets/create_graph_div');
55
var destroyGraphDiv = require('../assets/destroy_graph_div');
66
var failTest = require('../assets/fail_test');

test/jasmine/tests/config_test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
var Plotly = require('@lib/index');
2-
var Plots = Plotly.Plots;
2+
var Plots = require('@src/plots/plots');
33
var Lib = require('@src/lib');
44

55
var d3Select = require('../../strict-d3').select;
@@ -687,7 +687,7 @@ describe('config argument', function() {
687687
fillParent(1, 1);
688688
var cntWindowResize = 0;
689689
window.addEventListener('resize', function() {cntWindowResize++;});
690-
spyOn(Plotly.Plots, 'resize').and.callThrough();
690+
spyOn(Plots, 'resize').and.callThrough();
691691

692692
Plotly.newPlot(gd, data, {}, {responsive: true})
693693
.then(function() {return Plotly.restyle(gd, 'y[0]', data[0].y[0] + 2);})
@@ -696,7 +696,7 @@ describe('config argument', function() {
696696
// .then(function() {viewport.set(newWidth, 2 * newHeight);}).then(delay(200))
697697
.then(function() {
698698
expect(cntWindowResize).toBe(1);
699-
expect(Plotly.Plots.resize.calls.count()).toBe(1);
699+
expect(Plots.resize.calls.count()).toBe(1);
700700
})
701701
.then(done, done.fail);
702702
});
@@ -807,7 +807,7 @@ describe('config argument', function() {
807807
});
808808

809809
it('should not resize if gd is hidden', function(done) {
810-
spyOn(Plotly.Plots, 'resize').and.callThrough();
810+
spyOn(Plots, 'resize').and.callThrough();
811811

812812
fillParent(1, 1);
813813
Plotly.newPlot(gd, data, {}, {responsive: true})
@@ -817,7 +817,7 @@ describe('config argument', function() {
817817
})
818818
.then(delay(RESIZE_DELAY))
819819
.then(function() {
820-
expect(Plotly.Plots.resize.calls.count()).toBe(0);
820+
expect(Plots.resize.calls.count()).toBe(0);
821821
})
822822
.then(done, done.fail);
823823
});

test/jasmine/tests/transition_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var Plotly = require('@lib/index');
22
var Lib = require('@src/lib');
3-
var Plots = Plotly.Plots;
3+
var Plots = require('@src/plots/plots');
44
var plotApiHelpers = require('@src/plot_api/helpers');
55
var Axes = require('@src/plots/cartesian/axes');
66
var Registry = require('@src/registry');

0 commit comments

Comments
 (0)