我正在使用此功能以对数刻度显示负值。一切正常,除非我输入非常小的数字:
[8,6.986e-8],[14.947368421052632,1.705e-7],[21.894736842105264,3.299e-7],[28.842105263157897,5.606e-7],[35.78947368421053,8.765e-7],[42.73684210526316 ,0.000001292]
在这种情况下,y轴不会转移到对数。我对highcharts的内部功能原型没有深入的了解。 Highcharts版本是6.1.2。
// Pass error messages
H.Axis.prototype.allowNegativeLog = true;
// Override conversions
H.Axis.prototype.log2lin = function (num) {
var isNegative = num < 0,
adjustedNum = Math.abs(num),
result;
if (adjustedNum < 10) {
adjustedNum += (10 - adjustedNum) / 10;
}
result = Math.log(adjustedNum) / Math.LN10;
return isNegative ? -result : result;
};
H.Axis.prototype.lin2log = function (num) {
var isNegative = num < 0,
absNum = Math.abs(num),
result = Math.pow(10, absNum);
if (result < 10) {
result = (10 * (result - 1)) / (10 - 1);
}
return isNegative ? -result : result;
};
http://jsfiddle.net/9oLpayw1/(需要放入数据)