Skip to content

Commit 9187d53

Browse files
committed
histogram: remove gap when barmode is relative
1 parent 448cb14 commit 9187d53

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

src/traces/bar/layout_defaults.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,16 @@ module.exports = function(layoutIn, layoutOut, fullData) {
2424
var gappedAnyway = false;
2525
var usedSubplots = {};
2626

27+
var mode = coerce('barmode');
28+
2729
for(var i = 0; i < fullData.length; i++) {
2830
var trace = fullData[i];
2931
if(Registry.traceIs(trace, 'bar') && trace.visible) hasBars = true;
3032
else continue;
3133

3234
// if we have at least 2 grouped bar traces on the same subplot,
3335
// we should default to a gap anyway, even if the data is histograms
34-
if(layoutIn.barmode !== 'overlay' && layoutIn.barmode !== 'stack') {
36+
if(mode === 'group') {
3537
var subploti = trace.xaxis + trace.yaxis;
3638
if(usedSubplots[subploti]) gappedAnyway = true;
3739
usedSubplots[subploti] = true;
@@ -46,7 +48,6 @@ module.exports = function(layoutIn, layoutOut, fullData) {
4648

4749
if(!hasBars) return;
4850

49-
var mode = coerce('barmode');
5051
if(mode !== 'overlay') coerce('barnorm');
5152

5253
coerce('bargap', (shouldBeGapless && !gappedAnyway) ? 0 : 0.2);
Loading
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"data": [{
3+
"type": "histogram",
4+
"x": [9, 9, 3, 2, 5, 1, 3, 0, 6, 8, 5, 7, 2, 9, 9, 8, 5, 4, 1, 9, 2, 8, 0, 7, 2, 3, 5, 0, 3, 8, 2, 1, 7, 7, 7, 3, 9, 7, 8, 1, 7, 9, 4, 6, 2, 4, 2, 9, 3, 1, 5, 1, 6, 7, 6, 1, 6, 8, 6, 7, 8, 3, 7, 3, 1, 0, 2, 6, 1, 2, 7, 2, 9, 6, 2, 8, 0, 0, 9, 8, 5, 5, 8, 3, 5, 7, 7, 8, 3, 9, 3, 1, 5, 3, 5, 0, 8, 9, 4, 3]
5+
}, {
6+
"type": "histogram",
7+
"x": [6, 7, 8, 0, 8, 1, 5, 4, 4, 3, 4, 7, 5, 3, 9, 5, 2, 5, 5, 4, 3, 5, 2, 6, 3, 9, 8, 5, 3, 8, 7, 2, 2, 7, 3, 7, 0, 1, 1, 1, 2, 1, 4, 9, 3, 5, 4, 1, 1, 2, 0, 2, 8, 1, 0, 3, 1, 2, 3, 5, 3, 8, 6, 1, 1, 0, 0, 0, 8, 6, 0, 8, 6, 8, 0, 9, 4, 4, 0, 7, 7, 9, 2, 8, 0, 9, 0, 5, 7, 2, 9, 6, 5, 0, 0, 4, 6, 0, 9, 8]
8+
}],
9+
"layout": {
10+
"width": 600,
11+
"barmode": "relative"
12+
}
13+
}

0 commit comments

Comments
 (0)