Skip to content

Commit 6325990

Browse files
committed
redo PR 6120
1 parent 70a2f41 commit 6325990

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/plots/cartesian/axes.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,8 @@ axes.prepTicks = function(ax, opts) {
674674
minPx = ax.tickfont ? Lib.bigFont(ax.tickfont.size || 12) : 15;
675675
nt = ax._length / minPx;
676676
} else {
677-
minPx = ax._id.charAt(0) === 'y' ? 40 : 80;
677+
minPx = ax._id.charAt(0) === 'y' ? 40 :
678+
ax.loglabels === 'full value' ? 100 : 80;
678679
nt = Lib.constrain(ax._length / minPx, 4, 9) + 1;
679680
}
680681

@@ -1238,6 +1239,10 @@ axes.calcTicks = function calcTicks(ax, opts) {
12381239
return text;
12391240
}
12401241

1242+
var skipText1 = /^[346789]/; // for x-axis and tick length >= 3
1243+
var skipText2 = /^[4689]/; // for tick length < 3
1244+
var logFullValue = ax.loglabels === 'full value' && ax.dtick == 'D1';
1245+
12411246
var t;
12421247
for(i = 0; i < tickVals.length; i++) {
12431248
var _minor = tickVals[i].minor;
@@ -1259,6 +1264,14 @@ axes.calcTicks = function calcTicks(ax, opts) {
12591264
hideLabel(t);
12601265
}
12611266

1267+
if(logFullValue && ax._attr && (
1268+
(ax._attr[0] === 'y' && t.text.match(skipText2)) ||
1269+
(ax._attr[0] === 'x' && t.text.length < 3 && t.text.match(skipText2)) ||
1270+
(ax._attr[0] === 'x' && t.text.length >=3 && t.text.match(skipText1))
1271+
)) {
1272+
hideLabel(t);
1273+
}
1274+
12621275
ticksOut.push(t);
12631276
}
12641277
}
@@ -1470,11 +1483,14 @@ axes.autoTicks = function(ax, roughDTick, isMinor) {
14701483
Math.pow(10, rng[0])) / nt;
14711484
base = getBase(10);
14721485
ax.dtick = 'L' + roundDTick(roughDTick, base, roundBase10);
1486+
ax.tickformat = '';
14731487
} else {
14741488
// include intermediates between powers of 10,
14751489
// labeled with small digits
14761490
// ax.dtick = "D2" (show 2 and 5) or "D1" (show all digits)
1477-
ax.dtick = (roughDTick > 0.3) ? 'D2' : 'D1';
1491+
ax.dtick = (roughDTick > (ax.loglabels === 'full value' ? 0.4 : 0.3)) ? 'D2' : 'D1';
1492+
ax.tickformat = '0.1s';
1493+
ax.hoverformat = '0.2s'; // workaround to fix hoverinfo label formatting
14781494
}
14791495
} else if(ax.type === 'category' || ax.type === 'multicategory') {
14801496
ax.tick0 = 0;
@@ -3770,7 +3786,7 @@ axes.drawLabels = function(gd, ax, opts) {
37703786

37713787
var sel;
37723788
if(e.K === ZERO_PATH.K) {
3773-
var zerolineLayer = zerolineIsAbove ? mainPlotinfo.zerolinelayerAbove : mainPlotinfo.zerolinelayer;
3789+
var zerolineLayer = zerolineIsAbove ? mainPlotinfo.zerolinelayerAbove : mainPlotinfo.zerolinelayer;
37743790
sel = zerolineLayer.selectAll('.' + ax._id + 'zl');
37753791
} else if(e.K === MINORGRID_PATH.K) sel = mainPlotinfo.minorGridlayer.selectAll('.' + ax._id);
37763792
else if(e.K === GRID_PATH.K) sel = mainPlotinfo.gridlayer.selectAll('.' + ax._id);

0 commit comments

Comments
 (0)