Skip to content

Commit 0d6bca6

Browse files
authored
Merge pull request #6885 from plotly/bugfix-categorical-axis-tickson-boundaries-showgrid
Bugfix: categorical axis tickson boundaries showgrid
2 parents 08e06bd + e94f91a commit 0d6bca6

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

draftlogs/6885_change.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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!

src/plots/cartesian/axes.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2807,7 +2807,7 @@ function getBoundaryVals(ax, vals) {
28072807
// boundaryVals are never used for labels;
28082808
// no need to worry about the other tickTextObj keys
28092809
var _push = function(d, bndIndex) {
2810-
var xb = d.xbnd[bndIndex];
2810+
var xb = d.xbnd ? d.xbnd[bndIndex] : d.x;
28112811
if(xb !== null) {
28122812
out.push(Lib.extendFlat({}, d, {x: xb}));
28132813
}
@@ -3755,7 +3755,7 @@ axes.drawLabels = function(gd, ax, opts) {
37553755
// TODO should secondary labels also fall into this fix-overlap regime?
37563756

37573757
for(i = 0; i < lbbArray.length; i++) {
3758-
var xbnd = vals[i].xbnd;
3758+
var xbnd = (vals && vals[i].xbnd) ? vals[i].xbnd : [null, null];
37593759
var lbb = lbbArray[i];
37603760
if(
37613761
(xbnd[0] !== null && (lbb.left - ax.l2p(xbnd[0])) < gap) ||
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"data": [
3+
{
4+
"type": "bar",
5+
"y": [1, 2, 3, 4, 5],
6+
"x": ["a", "b", "c", "d", "e"]
7+
}
8+
],
9+
"layout": {
10+
"width": 600,
11+
"height": 300,
12+
"xaxis": {
13+
"tickmode": "array",
14+
"tickvals": [0,2,4],
15+
"ticktext": ["One", "Three", "Five"],
16+
"tickson": "boundaries",
17+
"showgrid": true
18+
}
19+
}
20+
}

0 commit comments

Comments
 (0)