Skip to content

Commit a7f49a0

Browse files
committed
prohibit bingroup for traces using different calendars
1 parent 79d78ab commit a7f49a0

File tree

2 files changed

+47
-15
lines changed

2 files changed

+47
-15
lines changed

Diff for: src/traces/histogram/cross_trace_defaults.js

+28-15
Original file line numberDiff line numberDiff line change
@@ -56,33 +56,46 @@ module.exports = function crossTraceDefaults(fullData, fullLayout) {
5656
if(!groupName) groupName = fallbackGroupName;
5757

5858
var axType = getAxisType(traceOut, binDir);
59+
var calendar = traceOut[binDir + 'calendar'];
5960
var binOpts = allBinOpts[groupName];
61+
var needsNewItem = true;
6062

6163
if(binOpts) {
62-
if(axType === binOpts.axType) {
64+
if(axType === binOpts.axType && calendar === binOpts.calendar) {
65+
needsNewItem = false;
6366
binOpts.traces.push(traceOut);
6467
binOpts.dirs.push(binDir);
6568
} else {
6669
groupName = fallbackGroupName;
67-
allBinOpts[groupName] = {
68-
traces: [traceOut],
69-
dirs: [binDir],
70-
axType: axType
71-
};
72-
Lib.warn([
73-
'Attempted to group the bins of trace', traceOut.index,
74-
'set on a', 'type:' + axType, 'axis',
75-
'with bins on', 'type:' + binOpts.axType, 'axis.'
76-
].join(' '));
70+
71+
if(axType !== binOpts.axType) {
72+
Lib.warn([
73+
'Attempted to group the bins of trace', traceOut.index,
74+
'set on a', 'type:' + axType, 'axis',
75+
'with bins on', 'type:' + binOpts.axType, 'axis.'
76+
].join(' '));
77+
}
78+
if(calendar !== binOpts.calendar) {
79+
// prohibit bingroup for traces using different calendar,
80+
// there's probably a way to make this work, but skip for now
81+
Lib.warn([
82+
'Attempted to group the bins of trace', traceOut.index,
83+
'set with a', calendar, 'calendar',
84+
'with bins',
85+
(binOpts.calendar ? 'on a ' + binOpts.calendar + ' calendar' : 'w/o a set calendar')
86+
].join(' '));
87+
}
7788
}
78-
} else {
79-
binOpts = allBinOpts[groupName] = {
89+
}
90+
91+
if(needsNewItem) {
92+
allBinOpts[groupName] = {
8093
traces: [traceOut],
8194
dirs: [binDir],
82-
axType: axType
95+
axType: axType,
96+
calendar: traceOut[binDir + 'calendar'] || ''
8397
};
8498
}
85-
8699
traceOut['_' + binDir + 'bingroup'] = groupName;
87100
}
88101

Diff for: test/jasmine/tests/histogram_test.js

+19
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,25 @@ describe('Test histogram', function() {
459459
['1', [0, 1, 3, 3, 2]]
460460
]);
461461
});
462+
463+
it('should not group traces across different calendars', function() {
464+
gd = {
465+
data: [
466+
{uid: 'a', bingroup: '1', type: 'histogram', x: ['2000-01-01']},
467+
{uid: 'b', bingroup: '1', type: 'histogram', x: ['2000-01-01'], xcalendar: 'julian'},
468+
],
469+
layout: {barmode: 'overlay'}
470+
};
471+
supplyAllDefaults(gd);
472+
473+
_assert('', [
474+
['1', [0]],
475+
['b__x', [1]]
476+
],
477+
'Attempted to group the bins of trace 1 set with a julian calendar ' +
478+
'with bins on a gregorian calendar'
479+
);
480+
});
462481
});
463482

464483
describe('calc', function() {

0 commit comments

Comments
 (0)