Skip to content

Commit 2381510

Browse files
committed
generalize setPositions for barpolar
1 parent 6a6d1dc commit 2381510

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

src/plot_api/plot_api.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,13 @@ exports.plot = function(gd, data, layout, config) {
329329
marginPushers,
330330
marginPushersAgain
331331
];
332+
332333
if(hasCartesian) seq.push(positionAndAutorange);
334+
else seq.push(Plots.doSetPositions);
335+
333336
seq.push(subroutines.layoutStyles);
334337
if(hasCartesian) seq.push(drawAxes);
338+
335339
seq.push(
336340
subroutines.drawData,
337341
subroutines.finalDraw,

src/plots/plots.js

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2566,24 +2566,40 @@ function clearAxesCalc(axList) {
25662566

25672567
plots.doSetPositions = function(gd) {
25682568
var fullLayout = gd._fullLayout;
2569-
var subplots = fullLayout._subplots.cartesian;
25702569
var modules = fullLayout._visibleModules;
2571-
var methods = [];
2572-
var i, j;
2570+
var hash = {};
2571+
var i, j, k;
25732572

25742573
// position and range calculations for traces that
25752574
// depend on each other ie bars (stacked or grouped)
25762575
// and boxes (grouped) push each other out of the way
25772576

25782577
for(j = 0; j < modules.length; j++) {
2579-
Lib.pushUnique(methods, modules[j].setPositions);
2578+
var _module = modules[j];
2579+
var fn = _module.setPositions;
2580+
if(fn) {
2581+
var spType = _module.basePlotModule.name;
2582+
if(hash[spType]) {
2583+
Lib.pushUnique(hash[spType], fn);
2584+
} else {
2585+
hash[spType] = [fn];
2586+
}
2587+
}
25802588
}
2581-
if(!methods.length) return;
25822589

2583-
for(i = 0; i < subplots.length; i++) {
2584-
var subplotInfo = fullLayout._plots[subplots[i]];
2585-
for(j = 0; j < methods.length; j++) {
2586-
methods[j](gd, subplotInfo);
2590+
for(k in hash) {
2591+
var methods = hash[k];
2592+
var subplots = fullLayout._subplots[k];
2593+
2594+
for(i = 0; i < subplots.length; i++) {
2595+
var sp = subplots[i];
2596+
var spInfo = k === 'cartesian' ?
2597+
fullLayout._plots[sp] :
2598+
fullLayout[sp];
2599+
2600+
for(j = 0; j < methods.length; j++) {
2601+
methods[j](gd, spInfo);
2602+
}
25872603
}
25882604
}
25892605
};

0 commit comments

Comments
 (0)