Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbf6909b

Browse files
authored
Merge pull request#7468 from plotly/loglabels
feat: Add `minorloglabels` to cartesian axes
2 parents251ae3c +12a6162 commitbf6909b

File tree

9 files changed

+173
-8
lines changed

9 files changed

+173
-8
lines changed

‎draftlogs/7468_add.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Add`minorloglabels` to cartesian axes[#7468](https://github.com/plotly/plotly.js/pull/7468)

‎src/plots/cartesian/axes.js‎

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1899,26 +1899,41 @@ function formatLog(ax, out, hover, extraPrecision, hideexp) {
18991899

19001900
if(tickformat||(dtChar0==='L')){
19011901
out.text=numFormat(Math.pow(10,x),ax,hideexp,extraPrecision);
1902-
}elseif(isNumeric(dtick)||((dtChar0==='D')&&(Lib.mod(x+0.01,1)<0.1))){
1903-
varp=Math.round(x);
1902+
}elseif(isNumeric(dtick)||((dtChar0==='D')&&
1903+
(ax.minorloglabels==='complete'||Lib.mod(x+0.01,1)<0.1))){
1904+
1905+
varisMinor;
1906+
if(ax.minorloglabels==='complete'&&!(Lib.mod(x+0.01,1)<0.1)){
1907+
isMinor=true;
1908+
out.fontSize*=0.75;
1909+
}
1910+
1911+
varexponentialString=Math.pow(10,x).toExponential(0);
1912+
varparts=exponentialString.split('e');
1913+
1914+
varp=+parts[1];
19041915
varabsP=Math.abs(p);
19051916
varexponentFormat=ax.exponentformat;
19061917
if(exponentFormat==='power'||(isSIFormat(exponentFormat)&&beyondSI(p))){
1907-
if(p===0)out.text=1;
1908-
elseif(p===1)out.text='10';
1909-
elseout.text='10<sup>'+(p>1 ?'' :MINUS_SIGN)+absP+'</sup>';
1918+
out.text=parts[0];
1919+
if(absP>0)out.text+='x10';
1920+
if(out.text==='1x10')out.text='10';
1921+
if(p!==0&&p!==1)out.text+='<sup>'+(p>0 ?'' :MINUS_SIGN)+absP+'</sup>';
19101922

19111923
out.fontSize*=1.25;
19121924
}elseif((exponentFormat==='e'||exponentFormat==='E')&&absP>2){
1913-
out.text='1'+exponentFormat+(p>0 ?'+' :MINUS_SIGN)+absP;
1925+
out.text=parts[0]+exponentFormat+(p>0 ?'+' :MINUS_SIGN)+absP;
19141926
}else{
19151927
out.text=numFormat(Math.pow(10,x),ax,'','fakehover');
19161928
if(dtick==='D1'&&ax._id.charAt(0)==='y'){
19171929
out.dy-=out.fontSize/6;
19181930
}
19191931
}
19201932
}elseif(dtChar0==='D'){
1921-
out.text=String(Math.round(Math.pow(10,Lib.mod(x,1))));
1933+
out.text=
1934+
ax.minorloglabels==='none' ?'' :
1935+
/* ax.minorloglabels === 'small digits' */String(Math.round(Math.pow(10,Lib.mod(x,1))));
1936+
19221937
out.fontSize*=0.75;
19231938
}elsethrow'unrecognized dtick '+String(dtick);
19241939

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

37713786
varsel;
37723787
if(e.K===ZERO_PATH.K){
3773-
varzerolineLayer=zerolineIsAbove ?mainPlotinfo.zerolinelayerAbove :mainPlotinfo.zerolinelayer;
3788+
varzerolineLayer=zerolineIsAbove ?mainPlotinfo.zerolinelayerAbove :mainPlotinfo.zerolinelayer;
37743789
sel=zerolineLayer.selectAll('.'+ax._id+'zl');
37753790
}elseif(e.K===MINORGRID_PATH.K)sel=mainPlotinfo.minorGridlayer.selectAll('.'+ax._id);
37763791
elseif(e.K===GRID_PATH.K)sel=mainPlotinfo.gridlayer.selectAll('.'+ax._id);

‎src/plots/cartesian/layout_attributes.js‎

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

1139+
minorloglabels:{
1140+
valType:'enumerated',
1141+
values:['small digits','complete','none'],
1142+
dflt:'small digits',
1143+
editType:'calc',
1144+
description:[
1145+
'Determines how minor log labels are displayed.',
1146+
'If *small digits*, small digits i.e. 2 or 5 are displayed.',
1147+
'If *complete*, complete digits are displayed.',
1148+
'If *none*, no labels are displayed.',
1149+
].join(' ')
1150+
},
1151+
11391152
layer:{
11401153
valType:'enumerated',
11411154
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.noMinorloglabels&&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+
noMinorloglabels: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,
125 KB
Loading
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{
2+
"data": [{
3+
"x": [0.001,0.01,0.1,1,10,100,1000],
4+
"y": [0,1,2,3,4,5,6]
5+
}, {
6+
"xaxis":"x2",
7+
"yaxis":"y2",
8+
"x": [0.001,0.01,0.1,1,10,100,1000],
9+
"y": [0,1,2,3,4,5,6]
10+
}, {
11+
"xaxis":"x3",
12+
"yaxis":"y3",
13+
"x": [0.001,0.01,0.1,1,10,100,1000],
14+
"y": [0,1,2,3,4,5,6]
15+
}, {
16+
"xaxis":"x4",
17+
"yaxis":"y4",
18+
"x": [0.00001,0.0001,0.001,0.01,0.1,1,10,100,1000,10000,10000,100000],
19+
"y": [0,1,2,3,4,5,6,7,8,9]
20+
}, {
21+
"xaxis":"x5",
22+
"yaxis":"y5",
23+
"x": [0.00001,0.0001,0.001,0.01,0.1,1,10,100,1000,10000,10000,100000],
24+
"y": [0,1,2,3,4,5,6,7,8,9]
25+
}, {
26+
"xaxis":"x6",
27+
"yaxis":"y6",
28+
"x": [0.00001,0.0001,0.001,0.01,0.1,1,10,100,1000,10000,10000,100000],
29+
"y": [0,1,2,3,4,5,6,7,8,9]
30+
}],
31+
"layout": {
32+
"grid": {
33+
"rows":7,
34+
"columns":1,
35+
"ygap":0.8,
36+
"pattern":"independent"
37+
},
38+
"xaxis": {
39+
"title": {"text":"none" },
40+
"type":"log",
41+
"minorloglabels":"none",
42+
"minor": {"showgrid":true }
43+
},
44+
"xaxis2": {
45+
"title": {"text":"small digits" },
46+
"dtick":"D1",
47+
"type":"log",
48+
"minorloglabels":"small digits"
49+
},
50+
"xaxis3": {
51+
"title": {"text":"small digits" },
52+
"dtick":"D2",
53+
"type":"log",
54+
"minorloglabels":"small digits"
55+
},
56+
"xaxis4": {
57+
"title": {"text":"complete" },
58+
"dtick":"D2",
59+
"type":"log",
60+
"minorloglabels":"complete",
61+
"minor": {"showgrid":true }
62+
},
63+
"xaxis5": {
64+
"title": {"text":"complete <br> exponentformat: 'e'" },
65+
"exponentformat":"e",
66+
"dtick":"D2",
67+
"type":"log",
68+
"minorloglabels":"complete",
69+
"minor": {"showgrid":true }
70+
},
71+
"xaxis6": {
72+
"title": {"text":"complete <br> exponentformat: 'power'" },
73+
"exponentformat":"power",
74+
"dtick":"D2",
75+
"type":"log",
76+
"minorloglabels":"complete",
77+
"minor": {"showgrid":true }
78+
},
79+
"title": {
80+
"text":"options of minorloglabels"
81+
},
82+
"width":1400,
83+
"height":1200,
84+
"showlegend":false
85+
}
86+
}

‎test/plot-schema.json‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5197,6 +5197,17 @@
51975197
"min": 0,
51985198
"valType": "number"
51995199
},
5200+
"minorloglabels": {
5201+
"description": "Determines how minor log labels are displayed. If *small digits*, small digits i.e. 2 or 5 are displayed. If *complete*, complete digits are displayed. If *none*, no labels are displayed.",
5202+
"dflt": "small digits",
5203+
"editType": "plot",
5204+
"valType": "enumerated",
5205+
"values": [
5206+
"small digits",
5207+
"complete",
5208+
"none"
5209+
]
5210+
},
52005211
"nticks": {
52015212
"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*.",
52025213
"dflt": 0,
@@ -5894,6 +5905,17 @@
58945905
"min": 0,
58955906
"valType": "number"
58965907
},
5908+
"minorloglabels": {
5909+
"description": "Determines how minor log labels are displayed. If *small digits*, small digits i.e. 2 or 5 are displayed. If *complete*, complete digits are displayed. If *none*, no labels are displayed.",
5910+
"dflt": "small digits",
5911+
"editType": "plot",
5912+
"valType": "enumerated",
5913+
"values": [
5914+
"small digits",
5915+
"complete",
5916+
"none"
5917+
]
5918+
},
58975919
"nticks": {
58985920
"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*.",
58995921
"dflt": 0,
@@ -13907,6 +13929,17 @@
1390713929
"valType": "number"
1390813930
}
1390913931
},
13932+
"minorloglabels": {
13933+
"description": "Determines how minor log labels are displayed. If *small digits*, small digits i.e. 2 or 5 are displayed. If *complete*, complete digits are displayed. If *none*, no labels are displayed.",
13934+
"dflt": "small digits",
13935+
"editType": "calc",
13936+
"valType": "enumerated",
13937+
"values": [
13938+
"small digits",
13939+
"complete",
13940+
"none"
13941+
]
13942+
},
1391013943
"mirror": {
1391113944
"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.",
1391213945
"dflt": false,
@@ -15468,6 +15501,17 @@
1546815501
"valType": "number"
1546915502
}
1547015503
},
15504+
"minorloglabels": {
15505+
"description": "Determines how minor log labels are displayed. If *small digits*, small digits i.e. 2 or 5 are displayed. If *complete*, complete digits are displayed. If *none*, no labels are displayed.",
15506+
"dflt": "small digits",
15507+
"editType": "calc",
15508+
"valType": "enumerated",
15509+
"values": [
15510+
"small digits",
15511+
"complete",
15512+
"none"
15513+
]
15514+
},
1547115515
"mirror": {
1547215516
"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.",
1547315517
"dflt": false,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp