generateVisibleLabels method

  1. @override
void generateVisibleLabels()
override

Generates the visible axis labels.

Implementation

@override
void generateVisibleLabels() {
  _axisDetails.visibleLabels = <AxisLabel>[];
  num prevInterval;
  final List<AxisLabel> label = _axisDetails.visibleLabels;
  int interval = _axisDetails.visibleRange!.minimum;
  interval = _axisDetails._alignRangeStart(
      this, interval, _axisDetails.visibleRange!.interval);
  while (interval <= _axisDetails.visibleRange!.maximum) {
    if (withInRange(interval, _axisDetails)) {
      prevInterval = (label.isNotEmpty)
          ? _axisDetails
              .visibleLabels[_axisDetails.visibleLabels.length - 1].value
          : interval;
      final DateFormat format = _axisDetails.dateTimeAxis.dateFormat ??
          getDateTimeLabelFormat(this, interval, prevInterval.toInt());

      String labelText =
          format.format(DateTime.fromMillisecondsSinceEpoch(interval));
      if (_axisDetails.dateTimeAxis.labelFormat != null &&
          _axisDetails.dateTimeAxis.labelFormat != '') {
        labelText = _axisDetails.dateTimeAxis.labelFormat!
            .replaceAll(RegExp('{value}'), labelText);
      }

      _axisDetails.triggerLabelRenderEvent(labelText, interval,
          _axisDetails.actualIntervalType, format.pattern!);
    }
    interval = _axisDetails
        ._increaseDateTimeInterval(
            this, interval, _axisDetails.visibleRange!.interval)
        .millisecondsSinceEpoch;
  }

  /// Get the maximum label of width and height in axis.
  _axisDetails.calculateMaximumLabelSize(this, _axisDetails.stateProperties);
  if (_axisDetails.dateTimeAxis.multiLevelLabels != null &&
      _axisDetails.dateTimeAxis.multiLevelLabels!.isNotEmpty) {
    generateMultiLevelLabels(_axisDetails);
    calculateMultiLevelLabelBounds(_axisDetails);
  }
}