How to use the recharts-scale.getTickValues function in recharts-scale

To help you get started, we’ve selected a few recharts-scale examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openforis / collect / collect-web / collect-webapp / frontend / vendor / recharts / src / util / CartesianUtils.js View on Github external
export const getTicksOfScale = (scale, opts) => {
  const { type, tickCount, ticks, originalDomain, allowDecimals } = opts;

  if (tickCount && type === 'number' && originalDomain && (
    originalDomain[0] === 'auto' || originalDomain[1] === 'auto')) {
    // Calculate the ticks by the number of grid when the axis is a number axis
    const domain = scale.domain();
    const tickValues = getNiceTickValues(domain, tickCount, allowDecimals);

    scale.domain(calculateDomainOfTicks(tickValues, type));

    return { niceTicks: tickValues };
  } else if (tickCount && type === 'number') {
    const domain = scale.domain();
    const tickValues = getTickValues(domain, tickCount, allowDecimals);

    return { niceTicks: tickValues };
  }

  return null;
};