Skip to content

Commit 49362b8

Browse files
committed
implement ticklabeljump on cartesian axes & colorbars
1 parent d971001 commit 49362b8

22 files changed

+352
-1
lines changed

src/components/colorbar/attributes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ module.exports = overrideAll({
166166
ticklen: axesAttrs.ticklen,
167167
tickwidth: axesAttrs.tickwidth,
168168
tickcolor: axesAttrs.tickcolor,
169+
ticklabeljump: axesAttrs.ticklabeljump,
169170
showticklabels: axesAttrs.showticklabels,
170171
tickfont: fontAttrs({
171172
description: 'Sets the color bar\'s tick label font'

src/components/colorbar/draw.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,7 @@ function mockColorBarAxis(gd, opts, zrange) {
933933
showticklabels: opts.showticklabels,
934934
ticklabelposition: opts.ticklabelposition,
935935
ticklabeloverflow: opts.ticklabeloverflow,
936+
ticklabeljump: opts.ticklabeljump,
936937
tickfont: opts.tickfont,
937938
tickangle: opts.tickangle,
938939
tickformat: opts.tickformat,

src/plots/cartesian/axes.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2966,7 +2966,11 @@ axes.drawLabels = function(gd, ax, opts) {
29662966
var axId = ax._id;
29672967
var axLetter = axId.charAt(0);
29682968
var cls = opts.cls || axId + 'tick';
2969-
var vals = opts.vals;
2969+
2970+
var jump = ax.ticklabeljump;
2971+
var vals = jump ?
2972+
opts.vals.filter(function(_, i) { return i % (jump + 1) === 0; }) :
2973+
opts.vals;
29702974

29712975
var labelFns = opts.labelFns;
29722976
var tickAngle = opts.secondary ? 0 : ax.tickangle;

src/plots/cartesian/layout_attributes.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,16 @@ module.exports = {
412412
'To set ticks every 4 years, set `dtick` to *M48*'
413413
].join(' ')
414414
},
415+
ticklabeljump: {
416+
valType: 'integer',
417+
min: 0,
418+
dflt: 0,
419+
editType: 'ticks',
420+
description: [
421+
'Sets the step between ticklabels.',
422+
'Could be used to hide labels between every n-th ticks.'
423+
].join(' ')
424+
},
415425
tickvals: {
416426
valType: 'data_array',
417427
editType: 'ticks',

src/plots/cartesian/tick_label_defaults.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ module.exports = function handleTickLabelDefaults(containerIn, containerOut, coe
2828
color: dfltFontColor
2929
});
3030

31+
if(!options.noTicklabeljump) coerce('ticklabeljump');
32+
3133
if(!options.noAng) coerce('tickangle');
3234

3335
if(axType !== 'category') {

src/plots/gl3d/layout/axis_defaults.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, options) {
4343
showGrid: true,
4444
noTickson: true,
4545
noTicklabelmode: true,
46+
noTicklabeljump: true,
4647
noTicklabelposition: true,
4748
noTicklabeloverflow: true,
4849
bgColor: options.bgColor,

src/plots/polar/layout_attributes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ var axisTickAttrs = overrideAll({
3232
ticklen: axesAttrs.ticklen,
3333
tickwidth: axesAttrs.tickwidth,
3434
tickcolor: axesAttrs.tickcolor,
35+
ticklabeljump: axesAttrs.ticklabeljump,
3536
showticklabels: axesAttrs.showticklabels,
3637
showtickprefix: axesAttrs.showtickprefix,
3738
tickprefix: axesAttrs.tickprefix,

src/plots/smith/layout_defaults.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ function handleDefaults(contIn, contOut, coerce, opts) {
8383
}
8484

8585
handleTickLabelDefaults(axIn, axOut, coerceAxis, axOut.type, {
86+
noTicklabeljump: true,
8687
noAng: !isRealAxis,
8788
noExp: true,
8889
font: {

src/plots/ternary/layout_attributes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ var ternaryAxesAttrs = {
2525
ticklen: axesAttrs.ticklen,
2626
tickwidth: axesAttrs.tickwidth,
2727
tickcolor: axesAttrs.tickcolor,
28+
ticklabeljump: axesAttrs.ticklabeljump,
2829
showticklabels: axesAttrs.showticklabels,
2930
showtickprefix: axesAttrs.showtickprefix,
3031
tickprefix: axesAttrs.tickprefix,

src/traces/carpet/ab_defaults.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ function mimickAxisDefaults(traceIn, traceOut, fullLayout, dfltColor) {
3030
var axOut = Template.newContainer(traceOut, axName);
3131

3232
var defaultOptions = {
33+
noTicklabeljump: true,
3334
tickfont: 'x',
3435
id: axLetter + 'axis',
3536
letter: axLetter,

0 commit comments

Comments
 (0)