Skip to content

Commit 1bb1c01

Browse files
committed
quick fix for plotly#1812: nticks and tickmode=array
1 parent 507308b commit 1bb1c01

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/plots/cartesian/axes.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ function arrayTicks(ax) {
702702
if(!Array.isArray(text)) text = [];
703703

704704
// make sure showing ticks doesn't accidentally add new categories
705-
// TODO multicategory, if we allow ticktext / tickvals
705+
// TODO multicategory, if we allow ticktext / fs
706706
var tickVal2l = ax.type === 'category' ? ax.d2l_noadd : ax.d2l;
707707

708708
// array ticks on log axes always show the full number
@@ -720,10 +720,14 @@ function arrayTicks(ax) {
720720
}
721721
}
722722

723+
if (ax._input && ax._input.nticks) {
724+
ax.nticks = ax._input.nticks;
725+
}
726+
723727
if(j < vals.length) ticksOut.splice(j, vals.length - j);
724728

725729
if(ax.rangebreaks) {
726-
// remove ticks falling inside rangebreaks
730+
// remove ticks falling inside rangebreakstickVals
727731
ticksOut = ticksOut.filter(function(d) {
728732
return ax.maskBreaks(d.x) !== BADNUM;
729733
});
@@ -2511,7 +2515,12 @@ axes.drawLabels = function(gd, ax, opts) {
25112515
// only so tex has predictable alignment that we can
25122516
// alter later
25132517
.attr('text-anchor', 'middle')
2514-
.each(function(d) {
2518+
.each(function(d, i) {
2519+
if (ax && ax.nticks
2520+
&& i != tickLabels[0].length - 1
2521+
&& i != 0 && d.x % ax.nticks != 0) {
2522+
return;
2523+
}
25152524
var thisLabel = d3.select(this);
25162525
var newPromise = gd._promises.length;
25172526

0 commit comments

Comments
 (0)