Skip to content
24 changes: 19 additions & 5 deletions src/plots/cartesian/axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -1558,7 +1558,8 @@ function autoTickRound(ax) {
var rangeexp = Math.floor(Math.log(maxend) / Math.LN10 + 0.01);
var minexponent = ax.minexponent === undefined ? 3 : ax.minexponent;
if(Math.abs(rangeexp) > minexponent) {
if(isSIFormat(ax.exponentformat) && !beyondSI(rangeexp)) {
if((isSIFormat(ax.exponentformat) && ax.exponentformat !== 'SI extended' && !beyondSI(rangeexp)) ||
(isSIFormat(ax.exponentformat) && ax.exponentformat === 'SI extended' && !beyondSIExtended(rangeexp))) {
ax._tickexponent = 3 * Math.round((rangeexp - 1) / 3);
} else ax._tickexponent = rangeexp;
}
Expand Down Expand Up @@ -1904,7 +1905,8 @@ function formatLog(ax, out, hover, extraPrecision, hideexp) {
var p = Math.round(x);
var absP = Math.abs(p);
var exponentFormat = ax.exponentformat;
if(exponentFormat === 'power' || (isSIFormat(exponentFormat) && beyondSI(p))) {
if(exponentFormat === 'power' || (isSIFormat(exponentFormat) && exponentFormat !== 'SI extended' && beyondSI(p)) ||
(isSIFormat(exponentFormat) && exponentFormat === 'SI extended' && beyondSIExtended(p))) {
if(p === 0) out.text = 1;
else if(p === 1) out.text = '10';
else out.text = '10<sup>' + (p > 1 ? '' : MINUS_SIGN) + absP + '</sup>';
Expand Down Expand Up @@ -2049,8 +2051,11 @@ function num2frac(num) {
// also automatically switch to sci. notation
var SIPREFIXES = ['f', 'p', 'n', 'μ', 'm', '', 'k', 'M', 'G', 'T'];

// extending SI prefixes
var SIPREFIXES_EXTENDED = ['q', 'r', 'y', 'z', 'a', 'f', 'p', 'n', 'μ', 'm', '', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y', 'R', 'Q'];

function isSIFormat(exponentFormat) {
return exponentFormat === 'SI' || exponentFormat === 'B';
return exponentFormat === 'SI' || exponentFormat === 'SI extended' || exponentFormat === 'B';
}

// are we beyond the range of common SI prefixes?
Expand All @@ -2064,6 +2069,10 @@ function beyondSI(exponent) {
return exponent > 14 || exponent < -15;
}

function beyondSIExtended(exponent) {
return exponent > 32 || exponent < -32;
}

function numFormat(v, ax, fmtoverride, hover) {
var isNeg = v < 0;
// max number of digits past decimal point to show
Expand Down Expand Up @@ -2139,7 +2148,8 @@ function numFormat(v, ax, fmtoverride, hover) {

// add exponent
if(exponent && exponentFormat !== 'hide') {
if(isSIFormat(exponentFormat) && beyondSI(exponent)) exponentFormat = 'power';
if((isSIFormat(exponentFormat) && exponentFormat !== 'SI extended' && beyondSI(exponent)) ||
(isSIFormat(exponentFormat) && exponentFormat === 'SI extended' && beyondSIExtended(exponent))) exponentFormat = 'power';

var signedExponent;
if(exponent < 0) signedExponent = MINUS_SIGN + -exponent;
Expand All @@ -2153,7 +2163,11 @@ function numFormat(v, ax, fmtoverride, hover) {
} else if(exponentFormat === 'B' && exponent === 9) {
v += 'B';
} else if(isSIFormat(exponentFormat)) {
v += SIPREFIXES[exponent / 3 + 5];
if(exponentFormat !== 'SI extended') {
v += SIPREFIXES[exponent / 3 + 5];
} else if(exponentFormat === 'SI extended') {
v += SIPREFIXES_EXTENDED[exponent / 3 + 10];
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/plots/cartesian/layout_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ module.exports = {
},
exponentformat: {
valType: 'enumerated',
values: ['none', 'e', 'E', 'power', 'SI', 'B'],
values: ['none', 'e', 'E', 'power', 'SI', 'B', 'SI extended'],
dflt: 'B',
editType: 'ticks',
description: [
Expand Down
2 changes: 1 addition & 1 deletion src/traces/carpet/axis_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ module.exports = {
},
exponentformat: {
valType: 'enumerated',
values: ['none', 'e', 'E', 'power', 'SI', 'B'],
values: ['none', 'e', 'E', 'power', 'SI', 'B', 'SI extended'],
dflt: 'B',
editType: 'calc',
description: [
Expand Down
Binary file modified test/image/baselines/20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions test/image/mocks/20.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
{
"x": [2, 3, 4],
"y": [40, 50, 60],
"y": [4000000000000, 5000000000000, 6000000000000],
"name": "yaxis2 data",
"yaxis": "y2",
"type": "scatter"
Expand Down Expand Up @@ -36,7 +36,7 @@
},
{
"x": [6, 7, 8],
"y": [4000000, 5000000, 6000000],
"y": [400000000000000000000000000000000, 500000000000000000000000000000000, 600000000000000000000000000000000],
"name": "yaxis6 data",
"yaxis": "y6",
"type": "scatter"
Expand Down Expand Up @@ -111,6 +111,7 @@
"tickfont": {
"color": "#ff7f0e"
},
"exponentformat": "SI",
"linecolor": "rgba(255,127,14,0.4)",
"linewidth": 6,
"anchor": "free",
Expand Down Expand Up @@ -189,7 +190,7 @@
"tickfont": {
"color": "#8c564b"
},
"exponentformat": "SI",
"exponentformat": "SI extended",
"linecolor": "rgba(140,86,75,0.5)",
"anchor": "free",
"side": "right",
Expand Down