SHARE
TWEET

Untitled

a guest Oct 21st, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //We want to extend Yaxis to have a little margin on top
  2.       //to do that we have to forceY on the chart.
  3.       //To determine that we're looking for the yrange power of ten corresponding to the difference
  4.       //in value between each tick
  5.       //then we round up to the next int corresponding to this power of ten
  6.       const decimalNumber = this.getYRangeDecimalNumber(
  7.         yRange,
  8.         yAxisTickNumber,
  9.       );
  10.       let tenPowToRoundUp = Math.pow(10, -decimalNumber);
  11.       //if decimalNumber equals 0 it means that the difference between each tick is more than 1
  12.       //so we have to determine the digit number to determine the corresponding power of ten
  13.       if (decimalNumber == 0) {
  14.         const yDiff = yRange[1] - yRange[0];
  15.         const tickDifference = yDiff / yAxisTickNumber; // difference between each tick value
  16.         tenPowToRoundUp = Math.pow(
  17.           10,
  18.           Math.floor(tickDifference).toString().length,
  19.         );
  20.       }
  21.       //e.g 73 will be round up to 100
  22.       const maxY = Math.ceil(yRange[1] / tenPowToRoundUp) * tenPowToRoundUp;
  23.       chart.forceY([maxY]);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top