有一个用 billboard.js 生成的图表我想更新 Y 轴的最小/最大值。
为此,我用 html 编写:
<span>
Max:</br>
<input ng-change="$ctrl.updateY()" ng-model="$ctrl.maxValue"></br>
Min:</br>
<input ng-change="$ctrl.updateY()" ng-model="$ctrl.minValue"></br>
</span>
在 JS 中:
updateY() {
this.lineView.chart.axis.max({y: this.maxValue});
this.lineView.chart.axis.min({y: this.minValue});
}
它对于 min
值工作正常,但对于 max
值则不然。
例如,如果我将最大值设置为 100
,则 Y 轴上的值为 1000
。
对于1000
,它是100000
。
对于10000
,它是1000000
。我猜它会额外加一个零,但没有找到如何以及在哪里。对于 min
一切都工作正常。这是一个错误吗?
有什么想法吗?
最佳答案
如果使用range()
而不是min()
和max()
,这个问题就可以解决。由于某种原因,它无法使用后面的方法正确更新。
updateY() {
const maxNumber = Number(this.maxValue);
const minNumber = Number(this.minValue);
this.lineView.chart.axis.range({max: {y: maxNumber}, min: {y: minNumber}});
}
关于javascript - Billboard.js 中图表的 Y 轴未正确更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48707042/