Skip to content

Commit 55b5338

Browse files
authored
Merge pull request #6910 from plotly/insiderange-categories
Fix insiderange with category axes
2 parents 9069e34 + 6f05ee4 commit 55b5338

File tree

4 files changed

+41
-6
lines changed

4 files changed

+41
-6
lines changed

draftlogs/6910_fix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Fix `insiderange` with category axes [[#6910](https://github.com/plotly/plotly.js/pull/6910)]

src/plots/cartesian/axes.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3907,13 +3907,13 @@ axes.drawLabels = function(gd, ax, opts) {
39073907

39083908
var anchorAxRange = anchorAx.range;
39093909

3910-
var p0 = anchorAx.d2p(anchorAxRange[index]);
3911-
var p1 = anchorAx.d2p(anchorAxRange[otherIndex]);
3910+
var p0 = anchorAx.r2p(anchorAxRange[index]);
3911+
var p1 = anchorAx.r2p(anchorAxRange[otherIndex]);
39123912

39133913
var _tempNewRange = fullLayout._insideTickLabelsUpdaterange[anchorAx._name + '.range'];
39143914
if(_tempNewRange) { // case of having multiple anchored axes having insideticklabel
3915-
var q0 = anchorAx.d2p(_tempNewRange[index]);
3916-
var q1 = anchorAx.d2p(_tempNewRange[otherIndex]);
3915+
var q0 = anchorAx.r2p(_tempNewRange[index]);
3916+
var q1 = anchorAx.r2p(_tempNewRange[otherIndex]);
39173917

39183918
var dir = sgn * (ax._id.charAt(0) === 'y' ? 1 : -1);
39193919

@@ -3938,8 +3938,8 @@ axes.drawLabels = function(gd, ax, opts) {
39383938

39393939
if(ax._id.charAt(0) !== 'y') move = -move;
39403940

3941-
newRange[index] = anchorAx.p2d(
3942-
anchorAx.d2p(anchorAxRange[index]) +
3941+
newRange[index] = anchorAx.p2r(
3942+
anchorAx.r2p(anchorAxRange[index]) +
39433943
sgn * move
39443944
);
39453945

9.85 KB
Loading
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"data": [
3+
{
4+
"name": "bar",
5+
"x": [
6+
"A",
7+
"B",
8+
"C",
9+
"D"
10+
],
11+
"y": [
12+
50,
13+
70,
14+
90,
15+
35
16+
],
17+
"type": "bar"
18+
}
19+
],
20+
"layout": {
21+
"xaxis": {
22+
"type": "category",
23+
"insiderange": [
24+
1,
25+
2
26+
]
27+
},
28+
"yaxis": {
29+
"side": "right",
30+
"ticklabelposition": "inside top"
31+
},
32+
"width": 400
33+
}
34+
}

0 commit comments

Comments
 (0)