0

There is a chart generated in Billboard.js which has the possibility to introduce custom values as minimum and maximum for the Y-axis.

The problem that I encounter is that even the axis is changing when the values are modified, they are not very close to the introduced value.

For example this screenshot:

enter image description here

On the maximum value I don't think it is a great problem. But on the minimum one it is. The default value was 0, after there was introduced 300 I would expect to start from a closer value to it, not 0 as before. The Y-axis just moved few pixels after that change.

The html code:

<input type="number" ng-change="$ctrl.updateY('max')" ng-model="$ctrl.max">

The JS code:

updateY(val) {
    if(val=== 'max') {
        if(this.max || this.max === 0) {
            this.maxValue = this.max;
        }
    } else {
        if(this.min || this.min === 0) {
            this.minValue = this.min;
        }
    }
    const maxNumber = Number(this.maxValue);
    const minNumber = Number(this.minValue);
    this.lineView.chart.axis.range({max: {y: maxNumber}, min: {y: minNumber}});
    this.resetY = false;
}

This is the code for max, same one for min.

I think that maybe the problem is from range, it doesn't generate the Y-axis with the values introduced.

Any suggestions?

Samurai Jack
  • 2,985
  • 8
  • 35
  • 58

1 Answers1

0

It is rendering much closer to the introduced values if it is added a padding in bb.generate:

const chart = bb.generate({
...
"axis": {
...
"y": {
...
        "padding" : {
        top: 0,
        bottom: 10
        }

...
Samurai Jack
  • 2,985
  • 8
  • 35
  • 58