Skip to content

Commit

Permalink
Merge pull request #5420 from plotly/simplify-Fx-and-Plots-APIs
Browse files Browse the repository at this point in the history
Drop various methods from Plotly.Fx and Plotly.Plots in the API
  • Loading branch information
archmoj authored Jan 19, 2021
2 parents 83f105d + 911b145 commit 9b30fea
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 13 deletions.
16 changes: 14 additions & 2 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,20 @@ if(window.PlotlyLocales && Array.isArray(window.PlotlyLocales)) {
exports.Icons = require('./fonts/ploticon');

// unofficial 'beta' plot methods, use at your own risk
exports.Plots = require('./plots/plots');
exports.Fx = require('./components/fx');
var Fx = require('./components/fx');
var Plots = require('./plots/plots');

exports.Plots = {
resize: Plots.resize,
graphJson: Plots.graphJson,
sendDataToCloud: Plots.sendDataToCloud
};
exports.Fx = {
hover: Fx.hover,
unhover: Fx.unhover,
loneHover: Fx.loneHover,
loneUnhover: Fx.loneUnhover
};
exports.Snapshot = require('./snapshot');
exports.PlotSchema = require('./plot_api/plot_schema');
exports.Queue = require('./lib/queue');
5 changes: 3 additions & 2 deletions test/jasmine/bundle_tests/finance_test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
var Plots = require('@src/plots/plots');
var Plotly = require('@lib/core');
var ohlc = require('@lib/ohlc');
var candlestick = require('@lib/candlestick');
Expand All @@ -14,13 +15,13 @@ describe('Bundle with finance trace type', function() {
var mock = require('@mocks/finance_style.json');

it('should not register transforms anymore', function() {
var transformModules = Object.keys(Plotly.Plots.transformsRegistry);
var transformModules = Object.keys(Plots.transformsRegistry);

expect(transformModules).toEqual([]);
});

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

// scatter is registered no matter what
// ohlc uses some parts of box by direct require but does not need to register it.
Expand Down
2 changes: 1 addition & 1 deletion test/jasmine/tests/animate_test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var Plotly = require('@lib/index');
var Lib = require('@src/lib');
var Registry = require('@src/registry');
var Plots = Plotly.Plots;
var Plots = require('@src/plots/plots');

var d3Select = require('../../strict-d3').select;
var d3SelectAll = require('../../strict-d3').selectAll;
Expand Down
3 changes: 2 additions & 1 deletion test/jasmine/tests/click_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var Plotly = require('@lib/index');
var Plots = require('@src/plots/plots');
var Lib = require('@src/lib');
var Drawing = require('@src/components/drawing');
var DBLCLICKDELAY = require('@src/plot_api/plot_config').dfltConfig.doubleClickDelay;
Expand Down Expand Up @@ -50,7 +51,7 @@ describe('Test click interactions:', function() {

function doubleClick(x, y) {
return doubleClickRaw(x, y).then(function() {
return Plotly.Plots.previousPromises(gd);
return Plots.previousPromises(gd);
});
}

Expand Down
2 changes: 1 addition & 1 deletion test/jasmine/tests/command_test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var Plotly = require('@lib/index');
var Registry = require('@src/registry');
var Plots = Plotly.Plots;
var Plots = require('@src/plots/plots');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');
Expand Down
10 changes: 5 additions & 5 deletions test/jasmine/tests/config_test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var Plotly = require('@lib/index');
var Plots = Plotly.Plots;
var Plots = require('@src/plots/plots');
var Lib = require('@src/lib');

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

Plotly.newPlot(gd, data, {}, {responsive: true})
.then(function() {return Plotly.restyle(gd, 'y[0]', data[0].y[0] + 2);})
Expand All @@ -696,7 +696,7 @@ describe('config argument', function() {
// .then(function() {viewport.set(newWidth, 2 * newHeight);}).then(delay(200))
.then(function() {
expect(cntWindowResize).toBe(1);
expect(Plotly.Plots.resize.calls.count()).toBe(1);
expect(Plots.resize.calls.count()).toBe(1);
})
.then(done, done.fail);
});
Expand Down Expand Up @@ -807,7 +807,7 @@ describe('config argument', function() {
});

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

fillParent(1, 1);
Plotly.newPlot(gd, data, {}, {responsive: true})
Expand All @@ -817,7 +817,7 @@ describe('config argument', function() {
})
.then(delay(RESIZE_DELAY))
.then(function() {
expect(Plotly.Plots.resize.calls.count()).toBe(0);
expect(Plots.resize.calls.count()).toBe(0);
})
.then(done, done.fail);
});
Expand Down
2 changes: 1 addition & 1 deletion test/jasmine/tests/transition_test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var Plotly = require('@lib/index');
var Lib = require('@src/lib');
var Plots = Plotly.Plots;
var Plots = require('@src/plots/plots');
var plotApiHelpers = require('@src/plot_api/helpers');
var Axes = require('@src/plots/cartesian/axes');
var Registry = require('@src/registry');
Expand Down

0 comments on commit 9b30fea

Please sign in to comment.