Skip to content

Commit ded6e94

Browse files
committed
update from calcInteractions to crossTraceCalc
and simplify by moving more stuff into doCalcdata
1 parent d50334e commit ded6e94

File tree

6 files changed

+19
-34
lines changed

6 files changed

+19
-34
lines changed

src/plot_api/plot_api.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -292,11 +292,6 @@ exports.plot = function(gd, data, layout, config) {
292292
return;
293293
}
294294

295-
Plots.doCrossTraceCalc(gd);
296-
297-
// calc and autorange for errorbars
298-
Registry.getComponentMethod('errorbars', 'calc')(gd);
299-
300295
// TODO: autosize extra for text markers and images
301296
// see https://github.com/plotly/plotly.js/issues/1111
302297
return Lib.syncOrAsync([
@@ -331,7 +326,6 @@ exports.plot = function(gd, data, layout, config) {
331326
];
332327

333328
if(hasCartesian) seq.push(positionAndAutorange);
334-
else seq.push(Plots.doCrossTraceCalc);
335329

336330
seq.push(subroutines.layoutStyles);
337331
if(hasCartesian) seq.push(drawAxes);

src/plots/plots.js

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2236,8 +2236,6 @@ plots.transition = function(gd, data, layout, traces, frameOpts, transitionOpts)
22362236

22372237
plots.supplyDefaults(gd);
22382238
plots.doCalcdata(gd);
2239-
plots.doCrossTraceCalc(gd);
2240-
Registry.getComponentMethod('errorbars', 'calc')(gd);
22412239

22422240
return Promise.resolve();
22432241
}
@@ -2503,8 +2501,6 @@ plots.doCalcdata = function(gd, traces) {
25032501
// clear stuff that should recomputed in 'regular' loop
25042502
if(hasCalcTransform) clearAxesCalc(axList);
25052503

2506-
var calcInteractionsFuncs = [];
2507-
25082504
function calci(i, isContainer) {
25092505
trace = fullData[i];
25102506
_module = trace._module;
@@ -2530,12 +2526,6 @@ plots.doCalcdata = function(gd, traces) {
25302526

25312527
if(_module && _module.calc) {
25322528
cd = _module.calc(gd, trace);
2533-
2534-
// Some modules need to update traces' calcdata after
2535-
// *all* traces have been through calc - so later traces can
2536-
// impact earlier traces.
2537-
var calcInteractions = _module.calcInteractions;
2538-
if(calcInteractions) Lib.pushUnique(calcInteractionsFuncs, calcInteractions);
25392529
}
25402530
}
25412531

@@ -2561,9 +2551,10 @@ plots.doCalcdata = function(gd, traces) {
25612551
for(i = 0; i < fullData.length; i++) calci(i, true);
25622552
for(i = 0; i < fullData.length; i++) calci(i, false);
25632553

2564-
for(i = 0; i < calcInteractionsFuncs.length; i++) calcInteractionsFuncs[i](gd, calcdata);
2554+
plots.doCrossTraceCalc(gd);
25652555

25662556
Registry.getComponentMethod('fx', 'calc')(gd);
2557+
Registry.getComponentMethod('errorbars', 'calc')(gd);
25672558
};
25682559

25692560
function clearAxesCalc(axList) {
@@ -2599,14 +2590,21 @@ plots.doCrossTraceCalc = function(gd) {
25992590
var methods = hash[k];
26002591
var subplots = fullLayout._subplots[k];
26012592

2602-
for(i = 0; i < subplots.length; i++) {
2603-
var sp = subplots[i];
2604-
var spInfo = k === 'cartesian' ?
2605-
fullLayout._plots[sp] :
2606-
fullLayout[sp];
2593+
if(Array.isArray(subplots)) {
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];
26072599

2600+
for(j = 0; j < methods.length; j++) {
2601+
methods[j](gd, spInfo);
2602+
}
2603+
}
2604+
}
2605+
else {
26082606
for(j = 0; j < methods.length; j++) {
2609-
methods[j](gd, spInfo);
2607+
methods[j](gd);
26102608
}
26112609
}
26122610
}

src/traces/pie/calc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,9 @@ exports.calc = function calc(gd, trace) {
130130
* This is done after sorting, so we pick defaults
131131
* in the order slices will be displayed
132132
*/
133-
exports.calcInteractions = function(gd, calcdata) {
133+
exports.crossTraceCalc = function(gd) {
134134
var fullLayout = gd._fullLayout;
135+
var calcdata = gd.calcdata;
135136
var pieColorWay = fullLayout.piecolorway;
136137
var colorMap = fullLayout._piecolormap;
137138

src/traces/pie/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Pie.layoutAttributes = require('./layout_attributes');
1717

1818
var calcModule = require('./calc');
1919
Pie.calc = calcModule.calc;
20-
Pie.calcInteractions = calcModule.calcInteractions;
20+
Pie.crossTraceCalc = calcModule.crossTraceCalc;
2121

2222
Pie.plot = require('./plot');
2323
Pie.style = require('./style');

test/jasmine/tests/annotations_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ describe('annotations autorange', function() {
775775
});
776776
})
777777
.then(function() {
778-
_assert('auto rng / big tx', [-0.22, 3.57], [0.84, 3.365]);
778+
_assert('auto rng / big tx', [-0.22, 3.59], [0.84, 3.365]);
779779
return Plotly.relayout(gd, 'annotations[0].text', 'a');
780780
})
781781
.then(function() {

test/jasmine/tests/bar_test.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,14 +1801,6 @@ function mockBarPlot(dataWithoutTraceType, layout) {
18011801
supplyAllDefaults(gd);
18021802
Plots.doCalcdata(gd);
18031803

1804-
var plotinfo = {
1805-
xaxis: gd._fullLayout.xaxis,
1806-
yaxis: gd._fullLayout.yaxis
1807-
};
1808-
1809-
// call Bar.crossTraceCalc
1810-
Bar.crossTraceCalc(gd, plotinfo);
1811-
18121804
return gd;
18131805
}
18141806

0 commit comments

Comments
 (0)