From 05054f1e6008b9dcd2699e3f49b583195fc99363 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Mon, 23 Dec 2019 17:27:38 -0500 Subject: [PATCH 1/2] add fallback in trace calendar getter in Histogram.crossTraceCalc ... so that when the Calendars module isn't registered (thus making `_fullData[i].(x|y)calendar` undefined), we're still able to group traces in the correct bin groups --- src/traces/histogram/cross_trace_defaults.js | 2 +- test/jasmine/tests/histogram_test.js | 30 ++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/traces/histogram/cross_trace_defaults.js b/src/traces/histogram/cross_trace_defaults.js index c699cf7d50c..0fbfc4e6570 100644 --- a/src/traces/histogram/cross_trace_defaults.js +++ b/src/traces/histogram/cross_trace_defaults.js @@ -55,7 +55,7 @@ module.exports = function crossTraceDefaults(fullData, fullLayout) { if(!groupName) groupName = fallbackGroupName; var axType = getAxisType(traceOut, binDir); - var calendar = traceOut[binDir + 'calendar']; + var calendar = traceOut[binDir + 'calendar'] || ''; var binOpts = allBinOpts[groupName]; var needsNewItem = true; diff --git a/test/jasmine/tests/histogram_test.js b/test/jasmine/tests/histogram_test.js index 97bd6446205..9166efee1cc 100644 --- a/test/jasmine/tests/histogram_test.js +++ b/test/jasmine/tests/histogram_test.js @@ -1,6 +1,7 @@ var Plotly = require('@lib/index'); var Plots = require('@src/plots/plots'); var Lib = require('@src/lib'); +var Registry = require('@src/registry'); var setConvert = require('@src/plots/cartesian/set_convert'); var supplyDefaults = require('@src/traces/histogram/defaults'); @@ -478,6 +479,35 @@ describe('Test histogram', function() { ); }); + it('should not group traces across different calendars when the calendar module is not registered', function() { + var original = Registry.getComponentMethod; + var cnt = 0; + + spyOn(Registry, 'getComponentMethod').and.callFake(function() { + if(arguments[0] === 'calendars') { + cnt++; + return Lib.noop; + } else { + return original.call(arguments); + } + }); + + gd = { + data: [ + {uid: 'a', type: 'histogram', x: [1, 3]}, + {uid: 'b', type: 'histogram', x: [1, 20]} + ], + layout: {barmode: 'stack'} + }; + supplyAllDefaults(gd); + + _assert('', [ + ['xyx', [0, 1]] + ]); + + expect(cnt).toBe(3, '# of Registry.getComponentMethod calls for *calendars* methods'); + }); + it('should force traces that "have to match" to have same bingroup (alignmentgroup case)', function() { var traces; From ee9425153f753f42677be5bf1fefbca55119e7b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Mon, 23 Dec 2019 17:48:47 -0500 Subject: [PATCH 2/2] fixup test description --- test/jasmine/tests/histogram_test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/jasmine/tests/histogram_test.js b/test/jasmine/tests/histogram_test.js index 9166efee1cc..df31aa0a304 100644 --- a/test/jasmine/tests/histogram_test.js +++ b/test/jasmine/tests/histogram_test.js @@ -479,7 +479,7 @@ describe('Test histogram', function() { ); }); - it('should not group traces across different calendars when the calendar module is not registered', function() { + it('should attempt to group traces when the *calendars* module is not registered', function() { var original = Registry.getComponentMethod; var cnt = 0;