如何解决Highcharts对数刻度负解停止工作
我为带有对数刻度且值为负的图形生成图形代码。结果在下面的小提琴中。
我制作了处理诸如here之类的负值所需的函数,并且运行良好。但是由于某些日子,它不再起作用了。因此,我根据this article调整了代码,但仍然无法正常工作。请参阅我的JSFidddle:
(function (H) {
H.addEvent(H.Axis,'afterInit',function () {
const logarithmic = this.logarithmic;
if (logarithmic && this.options.custom.allowNegativeLog) {
// Avoid errors on negative numbers on a log axis
this.positiveValuesOnly = false;
// Override the converter functions
logarithmic.log2lin = num => {
const isNegative = num < 0;
let adjustedNum = Math.abs(num);
if (adjustedNum < 10) {
adjustedNum += (10 - adjustedNum) / 10;
}
const result = Math.log(adjustedNum) / Math.LN10;
return isNegative ? -result : result;
};
logarithmic.lin2log = num => {
const isNegative = num < 0;
let result = Math.pow(10,Math.abs(num));
if (result < 10) {
result = (10 * (result - 1)) / (10 - 1);
}
return isNegative ? -result : result;
};
}
});
}(Highcharts));
我得到一个错误10,但that description中的示例却一无所获。
这是怎么回事,我该如何修理?
解决方法
显然Highcharts对Axis定义进行了更改。 Y轴定义为:
yAxis:
{
type: 'logarithmic',allowNegativeLog: true,title:
{
text: 'Regen Spreiding ( mm)'
},min: 0.0,max: 25.40
},
现在需要(至少正在使用此修改):
type: 'logarithmic',custom:
{
allowNegativeLog: true,},
注意:这与修改后的函数H一起使用,该函数现在以:
开头H.addEvent(H.Axis,'afterInit',function () {
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。