src/getNiceTickValues.js
function getTickOfSingleValue(value, tickCount, allowDecimals) {
  let step = 1;
  // calculate the middle value of ticks
  let middle = new Decimal(value);

  if (!middle.isint() && allowDecimals) {
    const absVal = Math.abs(value);

    if (absVal < 1) {
      // The step should be a float number when the difference is smaller than 1
      step = new Decimal(10).pow(Arithmetic.getDigitCount(value) - 1);

      middle = new Decimal(Math.floor(middle.div(step).toNumber())).mul(step);
    } else if (absVal > 1) {
      // Return the maximum integer which is smaller than 'value' when 'value' is greater than 1
      middle = new Decimal(Math.floor(value));
    }
  } else if (value === 0) {
    middle = new Decimal(Math.floor((tickCount - 1) / 2));
  } else if (!allowDecimals) {
    middle = new Decimal(Math.floor(value));
  }

  const middleIndex = Math.floor((tickCount - 1) / 2);

  const fn = compose(
    map(n => middle.add(new Decimal(n - middleIndex).mul(step)).toNumber()),
    range,
  );

  return fn(0, tickCount);
}
function getTickOfSingleValue(value, tickCount, allowDecimals) {
  let step = 1;
  // calculate the middle value of ticks
  let middle = new Decimal(value);

  if (!middle.isint() && allowDecimals) {
    const absVal = Math.abs(value);

    if (absVal < 1) {
      // The step should be a float number when the difference is smaller than 1
      step = new Decimal(10).pow(Arithmetic.getDigitCount(value) - 1);

      middle = new Decimal(Math.floor(middle.div(step).toNumber())).mul(step);
    } else if (absVal > 1) {
      // Return the maximum integer which is smaller than 'value' when 'value' is greater than 1
      middle = new Decimal(Math.floor(value));
    }
  } else if (value === 0) {
    middle = new Decimal(Math.floor((tickCount - 1) / 2));
  } else if (!allowDecimals) {
    middle = new Decimal(Math.floor(value));
  }

  const middleIndex = Math.floor((tickCount - 1) / 2);

  const fn = compose(
    map(n => middle.add(new Decimal(n - middleIndex).mul(step)).toNumber()),
    range,
  );

  return fn(0, tickCount);
}
function getTickOfSingleValue ( value , tickCount , allowDecimals ) { let step = 1 ; // calculate the middle value of ticks let middle = new Decimal ( value ) ; if ( ! middle . isint ( ) && allowDecimals ) { const absVal = Math . abs ( value ) ; if ( absVal < 1 ) { // The step should be a float number when the difference is smaller than 1 step = new Decimal ( 10 ) . pow ( Arithmetic . getDigitCount ( value ) - 1 ) ; middle = new Decimal ( Math . floor ( middle . div ( step ) . toNumber ( ) ) ) . mul ( step ) ; } else if ( absVal > 1 ) { // Return the maximum integer which is smaller than 'value' when 'value' is greater than 1 middle = new Decimal ( Math . floor ( value ) ) ; } } else if ( value === 0 ) { middle = new Decimal ( Math . floor ( ( tickCount - 1 ) / 2 ) ) ; } else if ( ! allowDecimals ) { middle = new Decimal ( Math . floor ( value ) ) ; } const middleIndex = Math . floor ( ( tickCount - 1 ) / 2 ) ; const fn = compose ( map ( n => middle . add ( new Decimal ( n - middleIndex ) . mul ( step ) ) . toNumber ( ) ) , range , ) ; return fn ( 0 , tickCount ) ; }
calculate the ticks when the minimum value equals to the maximum value

@param  {Number}  value         The minimum valuue which is also the maximum value
@param  {Integer} tickCount     The count of ticks
@param  {Boolean} allowDecimals Allow the ticks to be decimals or not
@return {Array}                 ticks
calculate the ticks when the minimum value equals to the maximum value