Skip to content

Commit 969e0af

Browse files
authored
Merge pull request #1369 from plotly/bar-skip-placeholder-traces
Skip over placeholder calc traces in bar set positions
2 parents 53ba120 + 7980cc6 commit 969e0af

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

src/traces/bar/set_positions.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ module.exports = function setPositions(gd, plotinfo) {
3737
fullTrace.visible === true &&
3838
Registry.traceIs(fullTrace, 'bar') &&
3939
fullTrace.xaxis === xa._id &&
40-
fullTrace.yaxis === ya._id
40+
fullTrace.yaxis === ya._id &&
41+
!calcTraces[i][0].placeholder
4142
) {
4243
if(fullTrace.orientation === 'h') {
4344
calcTracesHorizontal.push(calcTraces[i]);

test/jasmine/tests/bar_test.js

+18-11
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,23 @@ describe('Bar.setPositions', function() {
680680
expect(Axes.getAutoRange(xa)).toBeCloseToArray([-0.5, 2.5], undefined, '(xa.range)');
681681
expect(Axes.getAutoRange(ya)).toBeCloseToArray([-1.11, 1.11], undefined, '(ya.range)');
682682
});
683+
684+
it('should skip placeholder trace in position computations', function() {
685+
var gd = mockBarPlot([{
686+
x: [1, 2, 3],
687+
y: [2, 1, 2]
688+
}, {
689+
x: [null],
690+
y: [null]
691+
}]);
692+
693+
expect(gd.calcdata[0][0].t.barwidth).toEqual(0.8);
694+
695+
expect(gd.calcdata[1][0].x).toBe(false);
696+
expect(gd.calcdata[1][0].y).toBe(false);
697+
expect(gd.calcdata[1][0].placeholder).toBe(true);
698+
expect(gd.calcdata[1][0].t.barwidth).toBeUndefined();
699+
});
683700
});
684701

685702
describe('A bar plot', function() {
@@ -1231,18 +1248,8 @@ function mockBarPlot(dataWithoutTraceType, layout) {
12311248
calcdata: []
12321249
};
12331250

1234-
// call Bar.supplyDefaults
12351251
Plots.supplyDefaults(gd);
1236-
1237-
// call Bar.calc
1238-
gd._fullData.forEach(function(fullTrace) {
1239-
var cd = Bar.calc(gd, fullTrace);
1240-
1241-
cd[0].t = {};
1242-
cd[0].trace = fullTrace;
1243-
1244-
gd.calcdata.push(cd);
1245-
});
1252+
Plots.doCalcdata(gd);
12461253

12471254
var plotinfo = {
12481255
xaxis: gd._fullLayout.xaxis,

0 commit comments

Comments
 (0)