generateVisibleLabels method

  1. @override
void generateVisibleLabels()
override

Generates the visible axis labels.

Implementation

@override
void generateVisibleLabels() {
  num tempInterval = _axisDetails.visibleRange!.minimum;
  String labelText;
  _axisDetails.visibleLabels = <AxisLabel>[];
  for (;
      tempInterval <= _axisDetails.visibleRange!.maximum;
      tempInterval += _axisDetails.visibleRange!.interval) {
    labelText =
        pow(_axisDetails.logarithmicAxis.logBase, tempInterval).toString();

    labelText = double.parse(labelText) < 1
        ? labelText
        : double.parse(labelText).floor().toString();

    if (_axisDetails.logarithmicAxis.numberFormat != null) {
      labelText = _axisDetails.logarithmicAxis.numberFormat!
          .format(pow(_axisDetails.logarithmicAxis.logBase, tempInterval));
    }

    if (_axisDetails.logarithmicAxis.labelFormat != null &&
        _axisDetails.logarithmicAxis.labelFormat != '') {
      labelText = _axisDetails.logarithmicAxis.labelFormat!
          .replaceAll(RegExp('{value}'), labelText);
    }
    _axisDetails.triggerLabelRenderEvent(labelText, tempInterval);
  }

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