diff --git a/src/traces/sunburst/calc.js b/src/traces/sunburst/calc.js index e8a9a90d676..cb098662e5b 100644 --- a/src/traces/sunburst/calc.js +++ b/src/traces/sunburst/calc.js @@ -111,7 +111,10 @@ exports.calc = function(gd, trace) { label: k }); } else { - return Lib.warn('Multiple implied roots, cannot build ' + trace.type + ' hierarchy.'); + return Lib.warn([ + 'Multiple implied roots, cannot build', trace.type, 'hierarchy of', trace.name + '.', + 'These roots include:', impliedRoots.join(', ') + ].join(' ')); } } else if(parent2children[''].length > 1) { var dummyId = Lib.randstr(); @@ -140,7 +143,10 @@ exports.calc = function(gd, trace) { .id(function(d) { return d.id; }) .parentId(function(d) { return d.pid; })(cd); } catch(e) { - return Lib.warn('Failed to build ' + trace.type + ' hierarchy. Error: ' + e.message); + return Lib.warn([ + 'Failed to build', trace.type, 'hierarchy of', trace.name + '.', + 'Error:', e.message + ].join(' ')); } var hierarchy = d3Hierarchy.hierarchy(root); @@ -170,7 +176,7 @@ exports.calc = function(gd, trace) { if(v < partialSum * ALMOST_EQUAL) { failed = true; return Lib.warn([ - 'Total value for node', d.data.data.id, + 'Total value for node', d.data.data.id, 'of', trace.name, 'is smaller than the sum of its children.', '\nparent value =', v, '\nchildren sum =', partialSum diff --git a/test/jasmine/tests/sunburst_test.js b/test/jasmine/tests/sunburst_test.js index d78ee444c64..a59bb2e57fb 100644 --- a/test/jasmine/tests/sunburst_test.js +++ b/test/jasmine/tests/sunburst_test.js @@ -248,7 +248,7 @@ describe('Test sunburst calc:', function() { }); expect(Lib.warn).toHaveBeenCalledTimes(1); - expect(Lib.warn).toHaveBeenCalledWith('Multiple implied roots, cannot build sunburst hierarchy.'); + expect(Lib.warn).toHaveBeenCalledWith('Multiple implied roots, cannot build sunburst hierarchy of trace 0. These roots include: Root1, Root22'); }); it('should generate "root of roots" when it can', function() { @@ -299,8 +299,8 @@ describe('Test sunburst calc:', function() { expect(gd.calcdata[0][0].hierarchy).toBe(undefined, 'no computed hierarchy'); expect(Lib.warn).toHaveBeenCalledTimes(2); - expect(Lib.warn.calls.allArgs()[0][0]).toBe('Total value for node Root is smaller than the sum of its children. \nparent value = 0 \nchildren sum = 3'); - expect(Lib.warn.calls.allArgs()[1][0]).toBe('Total value for node B is smaller than the sum of its children. \nparent value = 2 \nchildren sum = 3'); + expect(Lib.warn.calls.allArgs()[0][0]).toBe('Total value for node Root of trace 0 is smaller than the sum of its children. \nparent value = 0 \nchildren sum = 3'); + expect(Lib.warn.calls.allArgs()[1][0]).toBe('Total value for node B of trace 0 is smaller than the sum of its children. \nparent value = 2 \nchildren sum = 3'); }); it('should warn labels/parents lead to ambiguous hierarchy', function() { @@ -310,7 +310,7 @@ describe('Test sunburst calc:', function() { }); expect(Lib.warn).toHaveBeenCalledTimes(1); - expect(Lib.warn).toHaveBeenCalledWith('Failed to build sunburst hierarchy. Error: ambiguous: A'); + expect(Lib.warn).toHaveBeenCalledWith('Failed to build sunburst hierarchy of trace 0. Error: ambiguous: A'); }); it('should warn ids/parents lead to ambiguous hierarchy', function() { @@ -321,7 +321,7 @@ describe('Test sunburst calc:', function() { }); expect(Lib.warn).toHaveBeenCalledTimes(1); - expect(Lib.warn).toHaveBeenCalledWith('Failed to build sunburst hierarchy. Error: ambiguous: b'); + expect(Lib.warn).toHaveBeenCalledWith('Failed to build sunburst hierarchy of trace 0. Error: ambiguous: b'); }); it('should accept numbers (even `0`) are ids/parents items', function() { diff --git a/test/jasmine/tests/treemap_test.js b/test/jasmine/tests/treemap_test.js index f5788260b2d..52374fc3cc4 100644 --- a/test/jasmine/tests/treemap_test.js +++ b/test/jasmine/tests/treemap_test.js @@ -363,7 +363,7 @@ describe('Test treemap calc:', function() { }); expect(Lib.warn).toHaveBeenCalledTimes(1); - expect(Lib.warn).toHaveBeenCalledWith('Multiple implied roots, cannot build treemap hierarchy.'); + expect(Lib.warn).toHaveBeenCalledWith('Multiple implied roots, cannot build treemap hierarchy of trace 0. These roots include: Root1, Root22'); }); it('should generate "root of roots" when it can', function() { @@ -414,8 +414,8 @@ describe('Test treemap calc:', function() { expect(gd.calcdata[0][0].hierarchy).toBe(undefined, 'no computed hierarchy'); expect(Lib.warn).toHaveBeenCalledTimes(2); - expect(Lib.warn.calls.allArgs()[0][0]).toBe('Total value for node Root is smaller than the sum of its children. \nparent value = 0 \nchildren sum = 3'); - expect(Lib.warn.calls.allArgs()[1][0]).toBe('Total value for node B is smaller than the sum of its children. \nparent value = 2 \nchildren sum = 3'); + expect(Lib.warn.calls.allArgs()[0][0]).toBe('Total value for node Root of trace 0 is smaller than the sum of its children. \nparent value = 0 \nchildren sum = 3'); + expect(Lib.warn.calls.allArgs()[1][0]).toBe('Total value for node B of trace 0 is smaller than the sum of its children. \nparent value = 2 \nchildren sum = 3'); }); it('should warn labels/parents lead to ambiguous hierarchy', function() { @@ -425,7 +425,7 @@ describe('Test treemap calc:', function() { }); expect(Lib.warn).toHaveBeenCalledTimes(1); - expect(Lib.warn).toHaveBeenCalledWith('Failed to build treemap hierarchy. Error: ambiguous: A'); + expect(Lib.warn).toHaveBeenCalledWith('Failed to build treemap hierarchy of trace 0. Error: ambiguous: A'); }); it('should warn ids/parents lead to ambiguous hierarchy', function() { @@ -436,7 +436,7 @@ describe('Test treemap calc:', function() { }); expect(Lib.warn).toHaveBeenCalledTimes(1); - expect(Lib.warn).toHaveBeenCalledWith('Failed to build treemap hierarchy. Error: ambiguous: b'); + expect(Lib.warn).toHaveBeenCalledWith('Failed to build treemap hierarchy of trace 0. Error: ambiguous: b'); }); it('should accept numbers (even `0`) are ids/parents items', function() {