Skip to content

Commit 0019cb0

Browse files
committed
Rename drawminorticklabel → ticklabelindex
1 parent ee329a3 commit 0019cb0

14 files changed

+50
-50
lines changed

draftlogs/7036_add.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
- Add axis property `drawminorticklabel` for drawing the label for each minor tick n positions away from a major tick [[#7036](https://github.com/plotly/plotly.js/pull/7036)]
1+
- Add axis property `ticklabelindex` for drawing the label for each minor tick n positions away from a major tick [[#7036](https://github.com/plotly/plotly.js/pull/7036)]

src/plots/cartesian/axes.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@ axes.calcTicks = function calcTicks(ax, opts) {
909909
var calendar = ax.calendar;
910910
var ticklabelstep = ax.ticklabelstep;
911911
var isPeriod = ax.ticklabelmode === 'period';
912-
var drawMinorTickLabel = ax.drawminorticklabel;
912+
var ticklabelIndex = ax.ticklabelindex;
913913
var rng = Lib.simpleMap(ax.range, ax.r2l, undefined, undefined, opts);
914914
var axrev = (rng[1] < rng[0]);
915915
var minRange = Math.min(rng[0], rng[1]);
@@ -923,7 +923,7 @@ axes.calcTicks = function calcTicks(ax, opts) {
923923
var tickVals = [];
924924
var minorTickVals = [];
925925
// all ticks for which labels are drawn which is not necessarily the major ticks when
926-
// `drawminorticklabel` is set.
926+
// `ticklabelindex` is set.
927927
var labelTickVals = [];
928928

929929
var hasMinor = ax.minor && (ax.minor.ticks || ax.minor.showgrid);
@@ -1079,20 +1079,20 @@ axes.calcTicks = function calcTicks(ax, opts) {
10791079
}
10801080
}
10811081

1082-
// check if drawMinorTickLabel makes sense, otherwise ignore it
1082+
// check if ticklabelIndex makes sense, otherwise ignore it
10831083
if(!minorTickVals || minorTickVals.length < 2) {
1084-
drawMinorTickLabel = false;
1084+
ticklabelIndex = false;
10851085
} else {
10861086
var diff = minorTickVals[1].value - minorTickVals[0].value;
10871087
if(!periodCompatibleWithTickformat(diff, ax.tickformat)) {
1088-
drawMinorTickLabel = false;
1088+
ticklabelIndex = false;
10891089
}
10901090
}
10911091
// Determine for which ticks to draw labels
1092-
if(!drawMinorTickLabel) {
1092+
if (!ticklabelIndex) {
10931093
labelTickVals = tickVals;
10941094
} else {
1095-
// Collect and sort all major and minor ticks, to find the minor ticks `drawMinorTickLabel`
1095+
// Collect and sort all major and minor ticks, to find the minor ticks `ticklabelIndex`
10961096
// steps away from each major tick. For those minor ticks we want to draw the label.
10971097

10981098
var allTickVals = tickVals.concat(minorTickVals);
@@ -1115,7 +1115,7 @@ axes.calcTicks = function calcTicks(ax, opts) {
11151115
.filter(function(index) { return index !== null; });
11161116

11171117
majorTickIndices.forEach(function(majorIdx) {
1118-
var minorIdx = majorIdx + drawMinorTickLabel;
1118+
var minorIdx = majorIdx + ticklabelIndex;
11191119
if(minorIdx >= 0 && minorIdx < allTickVals.length) {
11201120
labelTickVals.push(allTickVals[minorIdx]);
11211121
}
@@ -1239,7 +1239,7 @@ axes.calcTicks = function calcTicks(ax, opts) {
12391239
var _value = tickVals[i].value;
12401240

12411241
if(_minor) {
1242-
if(drawMinorTickLabel && labelTickVals.indexOf(tickVals[i]) !== -1) {
1242+
if (ticklabelIndex && labelTickVals.indexOf(tickVals[i]) !== -1) {
12431243
t = setTickLabel(ax, tickVals[i]);
12441244
} else {
12451245
t = { x: _value };
@@ -1250,7 +1250,7 @@ axes.calcTicks = function calcTicks(ax, opts) {
12501250
lastVisibleHead = ax._prevDateHead;
12511251
t = setTickLabel(ax, tickVals[i]);
12521252
if(tickVals[i].skipLabel ||
1253-
drawMinorTickLabel && labelTickVals.indexOf(tickVals[i]) === -1) {
1253+
ticklabelIndex && labelTickVals.indexOf(tickVals[i]) === -1) {
12541254
hideLabel(t);
12551255
}
12561256

src/plots/cartesian/axis_defaults.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce,
5959
}
6060
}
6161

62-
if(!options.noDrawminorticklabel && axType === 'date' && containerOut.ticklabelmode === 'period') {
63-
coerce('drawminorticklabel');
62+
if(!options.noTicklabelindex && axType === 'date' && containerOut.ticklabelmode === 'period') {
63+
coerce('ticklabelindex');
6464
}
6565

6666
var ticklabelposition = '';

src/plots/cartesian/layout_attributes.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -721,15 +721,15 @@ module.exports = {
721721
'outside and vice versa.'
722722
].join(' ')
723723
},
724-
drawminorticklabel: {
724+
ticklabelindex: {
725725
// In the future maybe add `arrayOk: true` for labeling several minor ticks, e.g. [-1, 0, 1]
726726
valType: 'integer',
727727
editType: 'calc',
728728
description: [
729729
'Only for date axes with `ticklabelmode` *period*.',
730730
'Instead of drawing the major tick label, draw the label for the minor tick',
731731
'that is n positions away from the major tick. E.g. to always draw the label for the',
732-
'minor tick before each major tick, choose `drawminorticklabel` -1'
732+
'minor tick before each major tick, choose `ticklabelindex` -1'
733733
].join(' ')
734734
},
735735
mirror: {

src/plots/gl3d/layout/axis_defaults.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, options) {
4242
data: options.data,
4343
showGrid: true,
4444
noAutotickangles: true,
45-
noDrawminorticklabel: true,
45+
noTicklabelindex: true,
4646
noTickson: true,
4747
noTicklabelmode: true,
4848
noTicklabelshift: true,

test/image/mocks/zzz_date_axes-ticklabelstep-drawminorticklabel.json renamed to test/image/mocks/zzz_date_axes-ticklabelstep-ticklabelindex.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@
158158
},
159159
"tickcolor": "red",
160160
"ticklabelmode": "period",
161-
"drawminorticklabel": 4,
161+
"ticklabelindex": 4,
162162
"anchor": "y"
163163
},
164164
"xaxis2": {
@@ -170,7 +170,7 @@
170170
"tickcolor": "red",
171171
"ticklabelmode": "period",
172172
"anchor": "y2",
173-
"drawminorticklabel": 1
173+
"ticklabelindex": 1
174174
},
175175
"xaxis3": {
176176
"ticklabelstep": 2,
@@ -181,7 +181,7 @@
181181
"tickcolor": "red",
182182
"ticklabelmode": "period",
183183
"anchor": "y3",
184-
"drawminorticklabel": 1
184+
"ticklabelindex": 1
185185
},
186186
"xaxis4": {
187187
"ticklabelstep": 2,
@@ -192,7 +192,7 @@
192192
"tickcolor": "red",
193193
"ticklabelmode": "period",
194194
"anchor": "y4",
195-
"drawminorticklabel": 1
195+
"ticklabelindex": 1
196196
},
197197
"xaxis5": {
198198
"ticklabelstep": 2,
@@ -203,7 +203,7 @@
203203
"tickcolor": "red",
204204
"ticklabelmode": "period",
205205
"anchor": "y5",
206-
"drawminorticklabel": -2
206+
"ticklabelindex": -2
207207
},
208208
"xaxis6": {
209209
"ticklabelstep": 2,
@@ -214,7 +214,7 @@
214214
"tickcolor": "red",
215215
"ticklabelmode": "period",
216216
"anchor": "y6",
217-
"drawminorticklabel": 2
217+
"ticklabelindex": 2
218218
},
219219
"xaxis7": {
220220
"ticklabelstep": 2,
@@ -225,7 +225,7 @@
225225
"tickcolor": "red",
226226
"ticklabelmode": "period",
227227
"anchor": "y7",
228-
"drawminorticklabel": -3
228+
"ticklabelindex": -3
229229
}
230230
}
231231
}

0 commit comments

Comments
 (0)