static getLabels()

in src/XAxisLabels.js [275:302]


  static getLabels(props) {
    const { tickCount, labelStyle, xScale } = defaults(
      props,
      {},
      XAxisLabels.defaultProps,
    );
    const ticks = props.ticks || getScaleTicks(xScale, null, tickCount);
    const style = {
      labelStyle,
      defaultStyle: XAxisLabels.defaultProps.labelStyle,
    };
    const propsFormats = props.format ? [props.format] : props.formats;
    const scaleType = inferScaleType(xScale);
    const formatStrs =
      Array.isArray(propsFormats) && propsFormats.length
        ? propsFormats
        : getDefaultFormats(scaleType);
    const formats = makeLabelFormatters(formatStrs, scaleType);

    // todo resolve ticks also
    // if there are so many ticks that no combination of labels can fit on the axis,
    // nudge down the tickCount and try again
    // doing this will require communicating the updated ticks/tickCount back to the parent element...

    const { labels } = resolveXLabelsForValues(xScale, ticks, formats, style);

    return labels;
  }