Billboard.js 图表的 Y 轴未正确更新
Y axis of chart doesn't update correctly in Billboard.js
有一个用 billboard.js 生成的图表,我想更新 Y 轴的 min/max 值。
为此,我在 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}});
}
有一个用 billboard.js 生成的图表,我想更新 Y 轴的 min/max 值。
为此,我在 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}});
}