Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //We want to extend Yaxis to have a little margin on top
- //to do that we have to forceY on the chart.
- //To determine that we're looking for the yrange power of ten corresponding to the difference
- //in value between each tick
- //then we round up to the next int corresponding to this power of ten
- const decimalNumber = this.getYRangeDecimalNumber(
- yRange,
- yAxisTickNumber,
- );
- let tenPowToRoundUp = Math.pow(10, -decimalNumber);
- //if decimalNumber equals 0 it means that the difference between each tick is more than 1
- //so we have to determine the digit number to determine the corresponding power of ten
- if (decimalNumber == 0) {
- const yDiff = yRange[1] - yRange[0];
- const tickDifference = yDiff / yAxisTickNumber; // difference between each tick value
- tenPowToRoundUp = Math.pow(
- 10,
- Math.floor(tickDifference).toString().length,
- );
- }
- //e.g 73 will be round up to 100
- const maxY = Math.ceil(yRange[1] / tenPowToRoundUp) * tenPowToRoundUp;
- chart.forceY([maxY]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement