Skip to content

Commit dead446

Browse files
authored
Merge pull request #3808 from plotly/fix3799-plot_api_exports
Group plot_api exports
2 parents 0c669de + 464437c commit dead446

File tree

1 file changed

+59
-36
lines changed

1 file changed

+59
-36
lines changed

src/plot_api/plot_api.js

+59-36
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ var numericNameWarningCountLimit = 5;
6666
* object containing `data`, `layout`, `config`, and `frames` members
6767
*
6868
*/
69-
exports.plot = function(gd, data, layout, config) {
69+
function plot(gd, data, layout, config) {
7070
var frames;
7171

7272
gd = Lib.getGraphDiv(gd);
@@ -391,7 +391,7 @@ exports.plot = function(gd, data, layout, config) {
391391
emitAfterPlot(gd);
392392
return gd;
393393
});
394-
};
394+
}
395395

396396
function emitAfterPlot(gd) {
397397
var fullLayout = gd._fullLayout;
@@ -403,9 +403,9 @@ function emitAfterPlot(gd) {
403403
}
404404
}
405405

406-
exports.setPlotConfig = function setPlotConfig(obj) {
406+
function setPlotConfig(obj) {
407407
return Lib.extendFlat(dfltConfig, obj);
408-
};
408+
}
409409

410410
function setBackground(gd, bgColor) {
411411
try {
@@ -622,7 +622,7 @@ function plotLegacyPolar(gd, data, layout) {
622622
}
623623

624624
// convenience function to force a full redraw, mostly for use by plotly.js
625-
exports.redraw = function(gd) {
625+
function redraw(gd) {
626626
gd = Lib.getGraphDiv(gd);
627627

628628
if(!Lib.isPlotDiv(gd)) {
@@ -637,7 +637,7 @@ exports.redraw = function(gd) {
637637
gd.emit('plotly_redraw');
638638
return gd;
639639
});
640-
};
640+
}
641641

642642
/**
643643
* Convenience function to make idempotent plot option obvious to users.
@@ -647,15 +647,15 @@ exports.redraw = function(gd) {
647647
* @param {Object} layout
648648
* @param {Object} config
649649
*/
650-
exports.newPlot = function(gd, data, layout, config) {
650+
function newPlot(gd, data, layout, config) {
651651
gd = Lib.getGraphDiv(gd);
652652

653653
// remove gl contexts
654654
Plots.cleanPlot([], {}, gd._fullData || [], gd._fullLayout || {});
655655

656656
Plots.purge(gd);
657657
return exports.plot(gd, data, layout, config);
658-
};
658+
}
659659

660660
/**
661661
* Wrap negative indicies to their positive counterparts.
@@ -975,7 +975,7 @@ function concatTypedArray(arr0, arr1) {
975975
* @param {Number|Object} [maxPoints] Number of points for trace window after lengthening.
976976
*
977977
*/
978-
exports.extendTraces = function extendTraces(gd, update, indices, maxPoints) {
978+
function extendTraces(gd, update, indices, maxPoints) {
979979
gd = Lib.getGraphDiv(gd);
980980

981981
function updateArray(target, insert, maxp) {
@@ -1031,9 +1031,9 @@ exports.extendTraces = function extendTraces(gd, update, indices, maxPoints) {
10311031
Queue.add(gd, exports.prependTraces, undoArgs, extendTraces, arguments);
10321032

10331033
return promise;
1034-
};
1034+
}
10351035

1036-
exports.prependTraces = function prependTraces(gd, update, indices, maxPoints) {
1036+
function prependTraces(gd, update, indices, maxPoints) {
10371037
gd = Lib.getGraphDiv(gd);
10381038

10391039
function updateArray(target, insert, maxp) {
@@ -1088,7 +1088,7 @@ exports.prependTraces = function prependTraces(gd, update, indices, maxPoints) {
10881088
Queue.add(gd, exports.extendTraces, undoArgs, prependTraces, arguments);
10891089

10901090
return promise;
1091-
};
1091+
}
10921092

10931093
/**
10941094
* Add data traces to an existing graph div.
@@ -1099,7 +1099,7 @@ exports.prependTraces = function prependTraces(gd, update, indices, maxPoints) {
10991099
* @param {Number[]|Number} [newIndices=[gd.data.length]] Locations to add traces
11001100
*
11011101
*/
1102-
exports.addTraces = function addTraces(gd, traces, newIndices) {
1102+
function addTraces(gd, traces, newIndices) {
11031103
gd = Lib.getGraphDiv(gd);
11041104

11051105
var currentIndices = [];
@@ -1164,7 +1164,7 @@ exports.addTraces = function addTraces(gd, traces, newIndices) {
11641164
promise = exports.moveTraces(gd, currentIndices, newIndices);
11651165
Queue.stopSequence(gd);
11661166
return promise;
1167-
};
1167+
}
11681168

11691169
/**
11701170
* Delete traces at `indices` from gd.data array.
@@ -1173,7 +1173,7 @@ exports.addTraces = function addTraces(gd, traces, newIndices) {
11731173
* @param {Object[]} gd.data The array of traces we're removing from
11741174
* @param {Number|Number[]} indices The indices
11751175
*/
1176-
exports.deleteTraces = function deleteTraces(gd, indices) {
1176+
function deleteTraces(gd, indices) {
11771177
gd = Lib.getGraphDiv(gd);
11781178

11791179
var traces = [];
@@ -1206,7 +1206,7 @@ exports.deleteTraces = function deleteTraces(gd, indices) {
12061206
Queue.add(gd, undoFunc, undoArgs, redoFunc, redoArgs);
12071207

12081208
return promise;
1209-
};
1209+
}
12101210

12111211
/**
12121212
* Move traces at currentIndices array to locations in newIndices array.
@@ -1239,7 +1239,7 @@ exports.deleteTraces = function deleteTraces(gd, indices) {
12391239
* // reorder all traces (assume there are 5--a, b, c, d, e)
12401240
* Plotly.moveTraces(gd, [b, d, e, a, c]) // same as 'move to end'
12411241
*/
1242-
exports.moveTraces = function moveTraces(gd, currentIndices, newIndices) {
1242+
function moveTraces(gd, currentIndices, newIndices) {
12431243
gd = Lib.getGraphDiv(gd);
12441244

12451245
var newData = [];
@@ -1303,7 +1303,7 @@ exports.moveTraces = function moveTraces(gd, currentIndices, newIndices) {
13031303
Queue.add(gd, undoFunc, undoArgs, redoFunc, redoArgs);
13041304

13051305
return promise;
1306-
};
1306+
}
13071307

13081308
/**
13091309
* restyle: update trace attributes of an existing plot
@@ -1405,7 +1405,6 @@ function restyle(gd, astr, val, _traces) {
14051405
return gd;
14061406
});
14071407
}
1408-
exports.restyle = restyle;
14091408

14101409
// for undo: undefined initial vals must be turned into nulls
14111410
// so that we unset rather than ignore them
@@ -1466,12 +1465,12 @@ function storeCurrent(attr, val, newVal, preGUI) {
14661465
* `layout._preGUI` or `layout._tracePreGUI[uid]`
14671466
* @param {object} edits: the {attr: val} object as normally passed to `relayout` etc
14681467
*/
1469-
exports._storeDirectGUIEdit = function(container, preGUI, edits) {
1468+
function _storeDirectGUIEdit(container, preGUI, edits) {
14701469
for(var attr in edits) {
14711470
var np = nestedProperty(container, attr);
14721471
storeCurrent(attr, np.get(), edits[attr], preGUI);
14731472
}
1474-
};
1473+
}
14751474

14761475
function _restyle(gd, aobj, traces) {
14771476
var fullLayout = gd._fullLayout;
@@ -1903,7 +1902,6 @@ function relayout(gd, astr, val) {
19031902
return gd;
19041903
});
19051904
}
1906-
exports.relayout = relayout;
19071905

19081906
// Optimization mostly for large splom traces where
19091907
// Plots.supplyDefaults can take > 100ms
@@ -2425,7 +2423,6 @@ function update(gd, traceUpdate, layoutUpdate, _traces) {
24252423
return gd;
24262424
});
24272425
}
2428-
exports.update = update;
24292426

24302427
/*
24312428
* internal-use-only restyle/relayout/update variants that record the initial
@@ -2440,9 +2437,6 @@ function guiEdit(func) {
24402437
return p;
24412438
};
24422439
}
2443-
exports._guiRestyle = guiEdit(restyle);
2444-
exports._guiRelayout = guiEdit(relayout);
2445-
exports._guiUpdate = guiEdit(update);
24462440

24472441
// For connecting edited layout attributes to uirevision attrs
24482442
// If no `attr` we use `match[1] + '.uirevision'`
@@ -2676,7 +2670,7 @@ function applyUIRevisions(data, layout, oldFullData, oldFullLayout) {
26762670
* object containing `data`, `layout`, `config`, and `frames` members
26772671
*
26782672
*/
2679-
exports.react = function(gd, data, layout, config) {
2673+
function react(gd, data, layout, config) {
26802674
var frames, plotDone;
26812675

26822676
function addFrames() { return exports.addFrames(gd, frames); }
@@ -2816,7 +2810,7 @@ exports.react = function(gd, data, layout, config) {
28162810

28172811
return gd;
28182812
});
2819-
};
2813+
}
28202814

28212815
function diffData(gd, oldFullData, newFullData, immutable, transition, newDataRevision) {
28222816
var sameTraceLength = oldFullData.length === newFullData.length;
@@ -3135,7 +3129,7 @@ function diffConfig(oldConfig, newConfig) {
31353129
* @param {object} animationOpts
31363130
* configuration for the animation
31373131
*/
3138-
exports.animate = function(gd, frameOrGroupNameOrFrameList, animationOpts) {
3132+
function animate(gd, frameOrGroupNameOrFrameList, animationOpts) {
31393133
gd = Lib.getGraphDiv(gd);
31403134

31413135
if(!Lib.isPlotDiv(gd)) {
@@ -3477,7 +3471,7 @@ exports.animate = function(gd, frameOrGroupNameOrFrameList, animationOpts) {
34773471
resolve();
34783472
}
34793473
});
3480-
};
3474+
}
34813475

34823476
/**
34833477
* Register new frames
@@ -3498,7 +3492,7 @@ exports.animate = function(gd, frameOrGroupNameOrFrameList, animationOpts) {
34983492
* provided, an index will be provided in serial order. If already used, the frame
34993493
* will be overwritten.
35003494
*/
3501-
exports.addFrames = function(gd, frameList, indices) {
3495+
function addFrames(gd, frameList, indices) {
35023496
gd = Lib.getGraphDiv(gd);
35033497

35043498
if(frameList === null || frameList === undefined) {
@@ -3615,7 +3609,7 @@ exports.addFrames = function(gd, frameList, indices) {
36153609
if(Queue) Queue.add(gd, undoFunc, undoArgs, redoFunc, redoArgs);
36163610

36173611
return Plots.modifyFrames(gd, ops);
3618-
};
3612+
}
36193613

36203614
/**
36213615
* Delete frame
@@ -3626,7 +3620,7 @@ exports.addFrames = function(gd, frameList, indices) {
36263620
* @param {array of integers} frameList
36273621
* list of integer indices of frames to be deleted
36283622
*/
3629-
exports.deleteFrames = function(gd, frameList) {
3623+
function deleteFrames(gd, frameList) {
36303624
gd = Lib.getGraphDiv(gd);
36313625

36323626
if(!Lib.isPlotDiv(gd)) {
@@ -3662,15 +3656,15 @@ exports.deleteFrames = function(gd, frameList) {
36623656
if(Queue) Queue.add(gd, undoFunc, undoArgs, redoFunc, redoArgs);
36633657

36643658
return Plots.modifyFrames(gd, ops);
3665-
};
3659+
}
36663660

36673661
/**
36683662
* Purge a graph container div back to its initial pre-Plotly.plot state
36693663
*
36703664
* @param {string id or DOM element} gd
36713665
* the id or DOM element of the graph container div
36723666
*/
3673-
exports.purge = function purge(gd) {
3667+
function purge(gd) {
36743668
gd = Lib.getGraphDiv(gd);
36753669

36763670
var fullLayout = gd._fullLayout || {};
@@ -3692,7 +3686,7 @@ exports.purge = function purge(gd) {
36923686
delete gd._context;
36933687

36943688
return gd;
3695-
};
3689+
}
36963690

36973691
// -------------------------------------------------------
36983692
// makePlotFramework: Create the plot container and axes
@@ -3829,3 +3823,32 @@ function makePlotFramework(gd) {
38293823

38303824
gd.emit('plotly_framework');
38313825
}
3826+
3827+
exports.animate = animate;
3828+
exports.addFrames = addFrames;
3829+
exports.deleteFrames = deleteFrames;
3830+
3831+
exports.addTraces = addTraces;
3832+
exports.deleteTraces = deleteTraces;
3833+
exports.extendTraces = extendTraces;
3834+
exports.moveTraces = moveTraces;
3835+
exports.prependTraces = prependTraces;
3836+
3837+
exports.newPlot = newPlot;
3838+
exports.plot = plot;
3839+
exports.purge = purge;
3840+
3841+
exports.react = react;
3842+
exports.redraw = redraw;
3843+
exports.relayout = relayout;
3844+
exports.restyle = restyle;
3845+
3846+
exports.setPlotConfig = setPlotConfig;
3847+
3848+
exports.update = update;
3849+
3850+
exports._guiRelayout = guiEdit(relayout);
3851+
exports._guiRestyle = guiEdit(restyle);
3852+
exports._guiUpdate = guiEdit(update);
3853+
3854+
exports._storeDirectGUIEdit = _storeDirectGUIEdit;

0 commit comments

Comments
 (0)