|
1 | 1 | var Plotly = require('@lib/index');
|
| 2 | +var Plots = require('@src/plots/plots'); |
2 | 3 | var Lib = require('@src/lib');
|
3 | 4 | var setConvert = require('@src/plots/cartesian/set_convert');
|
4 | 5 |
|
@@ -693,6 +694,14 @@ describe('Test histogram', function() {
|
693 | 694 | ]);
|
694 | 695 | });
|
695 | 696 |
|
| 697 | + it('handles multiple single-valued overlaid autobinned traces', function() { |
| 698 | + var out = _calc({x: [1]}, [{x: [1]}], {barmode: 'overlay'}, true); |
| 699 | + |
| 700 | + expect(out).toEqual([ |
| 701 | + {p: 1, s: 1, b: 0, pts: [0], ph1: 1, ph0: 1, width1: 1, i: 0} |
| 702 | + ]); |
| 703 | + }); |
| 704 | + |
696 | 705 | it('handles multiple single-valued overlaid autobinned traces with different values', function() {
|
697 | 706 | var out = _calc({x: [null, 13, '', 13]}, [
|
698 | 707 | {x: [5]},
|
@@ -752,6 +761,60 @@ describe('Test histogram', function() {
|
752 | 761 | ]);
|
753 | 762 | });
|
754 | 763 |
|
| 764 | + // from issue #3881 |
| 765 | + it('handle single-value edge case 1', function() { |
| 766 | + var gd = { |
| 767 | + data: [ |
| 768 | + {uid: 'a', type: 'histogram', y: [1]}, |
| 769 | + {uid: 'b', type: 'histogram', y: [2]}, |
| 770 | + |
| 771 | + {uid: 'c', type: 'histogram', y: [1], xaxis: 'x2'}, |
| 772 | + {uid: 'd', type: 'histogram', y: [3], xaxis: 'x2'}, |
| 773 | + |
| 774 | + {uid: 'e', type: 'histogram', y: [3]}, |
| 775 | + {uid: 'f', type: 'histogram', y: [2], xaxis: 'x2'}, |
| 776 | + |
| 777 | + {uid: 'g', type: 'histogram', x: [1]}, |
| 778 | + {uid: 'h', type: 'histogram', x: [2], yaxis: 'y2'}, |
| 779 | + {uid: 'i', type: 'histogram', x: [2]} |
| 780 | + ], |
| 781 | + layout: {barmode: 'overlay'} |
| 782 | + }; |
| 783 | + supplyAllDefaults(gd); |
| 784 | + Plots.doCalcdata(gd); |
| 785 | + |
| 786 | + var allBinOpts = gd._fullLayout._histogramBinOpts; |
| 787 | + var groups = Object.keys(allBinOpts); |
| 788 | + expect(groups).toEqual( |
| 789 | + ['a__y', 'b__y', 'c__y', 'd__y', 'e__y', 'f__y', 'g__x', 'h__x', 'i__x'], |
| 790 | + 'bin groups' |
| 791 | + ); |
| 792 | + }); |
| 793 | + |
| 794 | + // from issue #3881 |
| 795 | + it('handle single-value edge case 2', function() { |
| 796 | + var gd = { |
| 797 | + data: [ |
| 798 | + {bingroup: '1', type: 'histogram', y: [1]}, |
| 799 | + {uid: 'b', type: 'histogram', y: [2]}, |
| 800 | + {bingroup: '2', type: 'histogram', y: [1], xaxis: 'x2'}, |
| 801 | + {bingroup: '1', type: 'histogram', y: [3], xaxis: 'x2'}, |
| 802 | + {bingroup: '2', type: 'histogram', y: [3]}, |
| 803 | + {uid: 'f', type: 'histogram', y: [2], xaxis: 'x2'}, |
| 804 | + {bingroup: '3', type: 'histogram', x: [1]}, |
| 805 | + {bingroup: '1', type: 'histogram', x: [2], yaxis: 'y2'}, |
| 806 | + {bingroup: '3', type: 'histogram', x: [2]} |
| 807 | + ], |
| 808 | + layout: {barmode: 'overlay'} |
| 809 | + }; |
| 810 | + supplyAllDefaults(gd); |
| 811 | + Plots.doCalcdata(gd); |
| 812 | + |
| 813 | + var allBinOpts = gd._fullLayout._histogramBinOpts; |
| 814 | + var groups = Object.keys(allBinOpts); |
| 815 | + expect(groups).toEqual(['1', '2', '3', 'b__y', 'f__y'], 'bin groups'); |
| 816 | + }); |
| 817 | + |
755 | 818 | function calcPositions(opts, extraTraces, prepend) {
|
756 | 819 | return _calc(opts, extraTraces, {}, prepend).map(function(v) { return v.p; });
|
757 | 820 | }
|
|
0 commit comments