Skip to content

Commit 1ca31b6

Browse files
committed
add minorloglabels options
1 parent 021289c commit 1ca31b6

File tree

8 files changed

+130
-2
lines changed

8 files changed

+130
-2
lines changed

src/plots/cartesian/axes.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1918,7 +1918,12 @@ function formatLog(ax, out, hover, extraPrecision, hideexp) {
19181918
}
19191919
}
19201920
} else if(dtChar0 === 'D') {
1921-
out.text = String(Math.round(Math.pow(10, Lib.mod(x, 1))));
1921+
out.text =
1922+
ax.minorloglabels === 'exponential' ? Math.pow(10, x).toExponential(0) :
1923+
ax.minorloglabels === 'scientific' ? Math.pow(10, x).toExponential(0).replace(/e\+?/, 'x10<sup>') :
1924+
ax.minorloglabels === 'full value' ? Lib.numberFormat('0.1s')(Math.pow(10, x)) :
1925+
/* ax.minorloglabels === 'small digits' */ String(Math.round(Math.pow(10, Lib.mod(x, 1))));
1926+
19221927
out.fontSize *= 0.75;
19231928
} else throw 'unrecognized dtick ' + String(dtick);
19241929

@@ -3770,7 +3775,7 @@ axes.drawLabels = function(gd, ax, opts) {
37703775

37713776
var sel;
37723777
if(e.K === ZERO_PATH.K) {
3773-
var zerolineLayer = zerolineIsAbove ? mainPlotinfo.zerolinelayerAbove : mainPlotinfo.zerolinelayer;
3778+
var zerolineLayer = zerolineIsAbove ? mainPlotinfo.zerolinelayerAbove : mainPlotinfo.zerolinelayer;
37743779
sel = zerolineLayer.selectAll('.' + ax._id + 'zl');
37753780
} else if(e.K === MINORGRID_PATH.K) sel = mainPlotinfo.minorGridlayer.selectAll('.' + ax._id);
37763781
else if(e.K === GRID_PATH.K) sel = mainPlotinfo.gridlayer.selectAll('.' + ax._id);

src/plots/cartesian/layout_attributes.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,6 +1136,20 @@ module.exports = {
11361136
editType: 'ticks'
11371137
},
11381138

1139+
minorloglabels: {
1140+
valType: 'enumerated',
1141+
values: ['small digits', 'scientific', 'exponential', 'full value'],
1142+
dflt: 'small digits',
1143+
editType: 'calc',
1144+
description: [
1145+
'Determines how minor log labels are displayed.',
1146+
'If *small digits*, small digits are displayed.',
1147+
'If *exponential*, exponential notation is applied.',
1148+
'If *exponential*, scientific notation is applied.',
1149+
'If *full value*, full values are displayed.',
1150+
].join(' ')
1151+
},
1152+
11391153
layer: {
11401154
valType: 'enumerated',
11411155
values: ['above traces', 'below traces'],

src/plots/cartesian/tick_label_defaults.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ module.exports = function handleTickLabelDefaults(containerIn, containerOut, coe
7070
coerce('separatethousands');
7171
}
7272
}
73+
74+
if(!options.noLoglabels && axType === 'log') {
75+
coerce('minorloglabels');
76+
}
7377
}
7478
};
7579

src/plots/gl3d/layout/axis_defaults.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, options) {
4242
data: options.data,
4343
showGrid: true,
4444
noAutotickangles: true,
45+
noLoglabels: true,
4546
noTicklabelindex: true,
4647
noTickson: true,
4748
noTicklabelmode: true,

src/plots/polar/layout_attributes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ var axisTickAttrs = overrideAll({
3636
ticklabelstep: axesAttrs.ticklabelstep,
3737
showticklabels: axesAttrs.showticklabels,
3838
labelalias: axesAttrs.labelalias,
39+
minorloglabels: axesAttrs.minorloglabels,
3940
showtickprefix: axesAttrs.showtickprefix,
4041
tickprefix: axesAttrs.tickprefix,
4142
showticksuffix: axesAttrs.showticksuffix,
91.7 KB
Loading
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"data": [{
3+
"name": "small digits",
4+
"x": [0.001, 0.01, 0.1, 1, 10, 100, 1000],
5+
"y": [0, 1, 2, 3, 4, 5, 6]
6+
}, {
7+
"name": "exponential",
8+
"xaxis": "x2",
9+
"yaxis": "y2",
10+
"x": [0.001, 0.01, 0.1, 1, 10, 100, 1000],
11+
"y": [0, 1, 2, 3, 4, 5, 6]
12+
}, {
13+
"name": "scientific",
14+
"xaxis": "x3",
15+
"yaxis": "y3",
16+
"x": [0.001, 0.01, 0.1, 1, 10, 100, 1000],
17+
"y": [0, 1, 2, 3, 4, 5, 6]
18+
}, {
19+
"name": "full value",
20+
"xaxis": "x4",
21+
"yaxis": "y4",
22+
"x": [0.001, 0.01, 0.1, 1, 10, 100, 1000],
23+
"y": [0, 1, 2, 3, 4, 5, 6]
24+
}],
25+
"layout": {
26+
"grid": {
27+
"rows": 4,
28+
"columns": 1,
29+
"xgap": 0.25,
30+
"ygap": 0.25,
31+
"pattern": "independent"
32+
},
33+
"xaxis": {
34+
"type": "log",
35+
"minorloglabels": "small digits"
36+
},
37+
"xaxis2": {
38+
"type": "log",
39+
"minorloglabels": "exponential"
40+
},
41+
"xaxis3": {
42+
"type": "log",
43+
"minorloglabels": "scientific"
44+
},
45+
"xaxis4": {
46+
"type": "log",
47+
"minorloglabels": "full value"
48+
},
49+
"title": {
50+
"text": "options of minorloglabels"
51+
},
52+
"width": 1200,
53+
"height": 800
54+
}
55+
}

test/plot-schema.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5195,6 +5195,18 @@
51955195
"min": 0,
51965196
"valType": "number"
51975197
},
5198+
"minorloglabels": {
5199+
"description": "Determines how minor log labels are displayed. If *small digits*, small digits are displayed. If *exponential*, exponential notation is applied. If *exponential*, scientific notation is applied. If *full value*, full values are displayed.",
5200+
"dflt": "small digits",
5201+
"editType": "plot",
5202+
"valType": "enumerated",
5203+
"values": [
5204+
"small digits",
5205+
"scientific",
5206+
"exponential",
5207+
"full value"
5208+
]
5209+
},
51985210
"nticks": {
51995211
"description": "Specifies the maximum number of ticks for the particular axis. The actual number of ticks will be chosen automatically to be less than or equal to `nticks`. Has an effect only if `tickmode` is set to *auto*.",
52005212
"dflt": 0,
@@ -5892,6 +5904,18 @@
58925904
"min": 0,
58935905
"valType": "number"
58945906
},
5907+
"minorloglabels": {
5908+
"description": "Determines how minor log labels are displayed. If *small digits*, small digits are displayed. If *exponential*, exponential notation is applied. If *exponential*, scientific notation is applied. If *full value*, full values are displayed.",
5909+
"dflt": "small digits",
5910+
"editType": "plot",
5911+
"valType": "enumerated",
5912+
"values": [
5913+
"small digits",
5914+
"scientific",
5915+
"exponential",
5916+
"full value"
5917+
]
5918+
},
58955919
"nticks": {
58965920
"description": "Specifies the maximum number of ticks for the particular axis. The actual number of ticks will be chosen automatically to be less than or equal to `nticks`. Has an effect only if `tickmode` is set to *auto*.",
58975921
"dflt": 0,
@@ -13905,6 +13929,18 @@
1390513929
"valType": "number"
1390613930
}
1390713931
},
13932+
"minorloglabels": {
13933+
"description": "Determines how minor log labels are displayed. If *small digits*, small digits are displayed. If *exponential*, exponential notation is applied. If *exponential*, scientific notation is applied. If *full value*, full values are displayed.",
13934+
"dflt": "small digits",
13935+
"editType": "calc",
13936+
"valType": "enumerated",
13937+
"values": [
13938+
"small digits",
13939+
"scientific",
13940+
"exponential",
13941+
"full value"
13942+
]
13943+
},
1390813944
"mirror": {
1390913945
"description": "Determines if the axis lines or/and ticks are mirrored to the opposite side of the plotting area. If *true*, the axis lines are mirrored. If *ticks*, the axis lines and ticks are mirrored. If *false*, mirroring is disable. If *all*, axis lines are mirrored on all shared-axes subplots. If *allticks*, axis lines and ticks are mirrored on all shared-axes subplots.",
1391013946
"dflt": false,
@@ -15466,6 +15502,18 @@
1546615502
"valType": "number"
1546715503
}
1546815504
},
15505+
"minorloglabels": {
15506+
"description": "Determines how minor log labels are displayed. If *small digits*, small digits are displayed. If *exponential*, exponential notation is applied. If *exponential*, scientific notation is applied. If *full value*, full values are displayed.",
15507+
"dflt": "small digits",
15508+
"editType": "calc",
15509+
"valType": "enumerated",
15510+
"values": [
15511+
"small digits",
15512+
"scientific",
15513+
"exponential",
15514+
"full value"
15515+
]
15516+
},
1546915517
"mirror": {
1547015518
"description": "Determines if the axis lines or/and ticks are mirrored to the opposite side of the plotting area. If *true*, the axis lines are mirrored. If *ticks*, the axis lines and ticks are mirrored. If *false*, mirroring is disable. If *all*, axis lines are mirrored on all shared-axes subplots. If *allticks*, axis lines and ticks are mirrored on all shared-axes subplots.",
1547115519
"dflt": false,

0 commit comments

Comments
 (0)