Repository: mermaid-js/mermaid
File: packages/mermaid/src/diagrams/gantt/ganttRenderer.js (JavaScript)

Code before:
    rectangles
      .append('rect')
      .attr('id', (d) => 'exclude-' + d.start.format('YYYY-MM-DD'))
      .attr('x', (d) => timeScale(d.start.startOf('day')) + theSidePad)
      .attr('y', conf.gridLineStartPadding)
      .attr('width', (d) => timeScale(d.end.endOf('day')) - timeScale(d.start.startOf('day')))

      .attr('height', h - theTopPad - conf.gridLineStartPadding)
      .attr('transform-origin', function (d, i) {
        return (
          (
            timeScale(d.start) +
            theSidePad +
            0.5 * (timeScale(d.end) - timeScale(d.start))
          ).toString() +
          'px ' +
          (i * theGap + 0.5 * h).toString() +
          'px'
        );
      })
      .attr('class', 'exclude-range');
  }

  /**
   * Calculates the estimated number of ticks based on the time domain and tick interval.
   * Returns the count or Infinity if there would be too many ticks.
   * @param {Date} minTime - The minimum time in the domain
   * @param {Date} maxTime - The maximum time in the domain
   * @param {number} every - The interval count (e.g., 1 for "1second")
   * @param {string} interval - The interval unit (e.g., "second", "day")
   * @returns {number} The estimated number of ticks
   */
  function getEstimatedTickCount(minTime, maxTime, every, interval) {
    const timeDiffMs = maxTime - minTime;
    const intervalMs = dayjs.duration({ [interval ?? 'day']: every }).asMilliseconds();
    return Math.ceil(timeDiffMs / intervalMs);
  }

  /**
   * @param theSidePad
   * @param theTopPad
   * @param w
   * @param h
   */
  function makeGrid(theSidePad, theTopPad, w, h) {
    const dateFormat = diagObj.db.getDateFormat();
    const userAxisFormat = diagObj.db.getAxisFormat();
    let axisFormat;
    if (userAxisFormat) {
      axisFormat = userAxisFormat;
    } else if (dateFormat === 'D') {

Review comment (bug):
The JSDoc comment incorrectly states "Returns the count or Infinity if there would be too many ticks" but the function never returns `Infinity`. It always returns `Math.ceil(timeDiffMs / intervalMs)` regardless of the tick count. The documentation should be updated to reflect that the function simply calculates and returns the estimated tick count.
```suggestion
   * Returns the estimated number of ticks as a number.
```

Code after:
    rectangles
      .append('rect')
      .attr('id', (d) => 'exclude-' + d.start.format('YYYY-MM-DD'))
      .attr('x', (d) => timeScale(d.start.startOf('day')) + theSidePad)
      .attr('y', conf.gridLineStartPadding)
      .attr('width', (d) => timeScale(d.end.endOf('day')) - timeScale(d.start.startOf('day')))

      .attr('height', h - theTopPad - conf.gridLineStartPadding)
      .attr('transform-origin', function (d, i) {
        return (
          (
            timeScale(d.start) +
            theSidePad +
            0.5 * (timeScale(d.end) - timeScale(d.start))
          ).toString() +
          'px ' +
          (i * theGap + 0.5 * h).toString() +
          'px'
        );
      })
      .attr('class', 'exclude-range');
  }

  /**
   * Calculates the estimated number of ticks based on the time domain and tick interval.
   * Returns the estimated number of ticks as a number.
   * @param {Date} minTime - The minimum time in the domain
   * @param {Date} maxTime - The maximum time in the domain
   * @param {number} every - The interval count (e.g., 1 for "1second")
   * @param {string} interval - The interval unit (e.g., "second", "day")
   * @returns {number} The estimated number of ticks
   */
  function getEstimatedTickCount(minTime, maxTime, every, interval) {
    if (every <= 0 || minTime > maxTime) {
      return Infinity;
    }
    const timeDiffMs = maxTime - minTime;
    const intervalMs = dayjs.duration({ [interval ?? 'day']: every }).asMilliseconds();
    if (intervalMs <= 0) {
      return Infinity;
    }
    return Math.ceil(timeDiffMs / intervalMs);
  }

  /**
   * @param theSidePad
   * @param theTopPad
   * @param w
   * @param h
   */
  function makeGrid(theSidePad, theTopPad, w, h) {