有一个用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
,一切正常。这是一个错误吗?
有什么想法吗?
答案 0 :(得分:1)
如果使用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}});
}