diff --git a/draftlogs/6885_change.md b/draftlogs/6885_change.md new file mode 100644 index 00000000000..cb9ee3dd457 --- /dev/null +++ b/draftlogs/6885_change.md @@ -0,0 +1 @@ +- Fix bug where plots with axis `type='categorical'`, `tickson = "boundaries"` and `showgrid=true` wouldn't load, see [plotly.py # 3155](https://github.com/plotly/plotly.py/issues/3155). This feature was anonymously sponsored: thank you to our sponsor! \ No newline at end of file diff --git a/src/plots/cartesian/axes.js b/src/plots/cartesian/axes.js index ddd11e7b403..8c0c2094a22 100644 --- a/src/plots/cartesian/axes.js +++ b/src/plots/cartesian/axes.js @@ -2807,7 +2807,7 @@ function getBoundaryVals(ax, vals) { // boundaryVals are never used for labels; // no need to worry about the other tickTextObj keys var _push = function(d, bndIndex) { - var xb = d.xbnd[bndIndex]; + var xb = d.xbnd ? d.xbnd[bndIndex] : d.x; if(xb !== null) { out.push(Lib.extendFlat({}, d, {x: xb})); } @@ -3755,7 +3755,7 @@ axes.drawLabels = function(gd, ax, opts) { // TODO should secondary labels also fall into this fix-overlap regime? for(i = 0; i < lbbArray.length; i++) { - var xbnd = vals[i].xbnd; + var xbnd = (vals && vals[i].xbnd) ? vals[i].xbnd : [null, null]; var lbb = lbbArray[i]; if( (xbnd[0] !== null && (lbb.left - ax.l2p(xbnd[0])) < gap) || diff --git a/test/image/baselines/zz-tickson_boundaries_showgrid_categorical.png b/test/image/baselines/zz-tickson_boundaries_showgrid_categorical.png new file mode 100644 index 00000000000..8d4fb1d90df Binary files /dev/null and b/test/image/baselines/zz-tickson_boundaries_showgrid_categorical.png differ diff --git a/test/image/mocks/zz-tickson_boundaries_showgrid_categorical.json b/test/image/mocks/zz-tickson_boundaries_showgrid_categorical.json new file mode 100644 index 00000000000..5812b077d7e --- /dev/null +++ b/test/image/mocks/zz-tickson_boundaries_showgrid_categorical.json @@ -0,0 +1,20 @@ +{ + "data": [ + { + "type": "bar", + "y": [1, 2, 3, 4, 5], + "x": ["a", "b", "c", "d", "e"] + } + ], + "layout": { + "width": 600, + "height": 300, + "xaxis": { + "tickmode": "array", + "tickvals": [0,2,4], + "ticktext": ["One", "Three", "Five"], + "tickson": "boundaries", + "showgrid": true + } + } +}