Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/plots/plots.js
Original file line number Diff line number Diff line change
Expand Up @@ -579,8 +579,8 @@ function getTraceUids(oldFullData, newData) {
* Single-trace subplots (which have no `id`) such as pie, table, etc
* do not need to be collected because we just draw all visible traces.
*/
var collectableSubplotTypes;
function emptySubplotLists() {
var collectableSubplotTypes = Registry.collectableSubplotTypes;
var out = {};
var i, j;

Expand Down
3 changes: 3 additions & 0 deletions src/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ exports.layoutArrayRegexes = [];
exports.traceLayoutAttributes = {};
exports.localeRegistry = {};
exports.apiMethodRegistry = {};
exports.collectableSubplotTypes = null;

/**
* Top-level register routine, exported as Plotly.register
Expand Down Expand Up @@ -72,6 +73,8 @@ exports.apiMethodRegistry = {};
*
*/
exports.register = function register(_modules) {
exports.collectableSubplotTypes = null;

if(!_modules) {
throw new Error('No argument passed to Plotly.register.');
} else if(_modules && !Array.isArray(_modules)) {
Expand Down
40 changes: 40 additions & 0 deletions test/jasmine/bundle_tests/dynamic_import_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
var Plotly = require('@lib/core');

var d3 = require('d3');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var failTest = require('../assets/fail_test');

describe('Dynamic @lib/ module imports', function() {
var gd;

afterEach(destroyGraphDiv);

it('should work', function(done) {
gd = createGraphDiv();

Plotly.newPlot(gd, [{
y: [1, 2, 1]
}])
.then(function() {
// N.B. from a different subplot type
// more info in:
// https://github.com/plotly/plotly.js/issues/3428
var ScatterPolar = require('@lib/scatterpolar');
Plotly.register(ScatterPolar);
})
.then(function() {
return Plotly.newPlot(gd, [{
type: 'scatterpolar',
r: [1, 2, 1]
}]);
})
.then(function() {
var polarLayer = d3.select('.polarlayer');
expect(polarLayer.size()).toBe(1, 'one polar layer');
expect(polarLayer.selectAll('.trace').size()).toBe(1, 'one scatterpolar trace');
})
.catch(failTest)
.then(done);
});
});