calculateVisibleRange method Null safety

  1. @override
void calculateVisibleRange(
  1. Size availableSize
)
override

Calculates the visible range for an axis in chart.

Implementation

@override
void calculateVisibleRange(Size availableSize) {
  _axisDetails.setOldRangeFromRangeController();
  _axisDetails.visibleRange =
      _axisDetails.stateProperties.rangeChangeBySlider &&
              _axisDetails.rangeMinimum != null &&
              _axisDetails.rangeMaximum != null
          ? VisibleRange(_axisDetails.rangeMinimum, _axisDetails.rangeMaximum)
          : VisibleRange(_axisDetails.actualRange!.minimum,
              _axisDetails.actualRange!.maximum);
  _axisDetails.visibleRange!.delta = _axisDetails.actualRange!.delta;
  _axisDetails.visibleRange!.interval = _axisDetails.actualRange!.interval;
  bool canAutoScroll = false;
  if (_axisDetails.logarithmicAxis.autoScrollingDelta != null &&
      _axisDetails.logarithmicAxis.autoScrollingDelta! > 0 &&
      !_axisDetails.stateProperties.isRedrawByZoomPan) {
    canAutoScroll = true;
    _axisDetails.updateAutoScrollingDelta(
        _axisDetails.logarithmicAxis.autoScrollingDelta!, this);
  }
  if ((!canAutoScroll ||
          (_axisDetails.stateProperties.zoomedState ?? false)) &&
      !(_axisDetails.stateProperties.rangeChangeBySlider &&
          !_axisDetails.stateProperties.canSetRangeController)) {
    _axisDetails.setZoomFactorAndPosition(
        this, _axisDetails.stateProperties.zoomedAxisRendererStates);
  }
  if (_axisDetails.zoomFactor < 1 ||
      _axisDetails.zoomPosition > 0 ||
      (_axisDetails.axis.rangeController != null &&
              !_axisDetails
                  .stateProperties.renderingDetails.initialRender!) &&
          !(_axisDetails.stateProperties.rangeChangeBySlider ||
              !_axisDetails.stateProperties.canSetRangeController)) {
    _axisDetails.stateProperties.zoomProgress = true;
    _axisDetails.calculateZoomRange(this, availableSize);
    _axisDetails.visibleRange!.delta = _axisDetails.visibleRange!.maximum -
        _axisDetails.visibleRange!.minimum;
    _axisDetails.visibleRange!.interval =
        _axisDetails.axis.enableAutoIntervalOnZooming &&
                _axisDetails.stateProperties.zoomProgress
            ? (_axisDetails.axisRenderer as LogarithmicAxisRenderer)
                .calculateLogNiceInterval(_axisDetails.visibleRange!.delta)
            : _axisDetails.visibleRange!.interval;
    _axisDetails.visibleRange!.interval =
        _axisDetails.visibleRange!.interval.floor() == 0
            ? 1
            : _axisDetails.visibleRange!.interval.floor();
    if (_axisDetails.axis.rangeController != null &&
        _axisDetails.stateProperties.isRedrawByZoomPan &&
        _axisDetails.stateProperties.canSetRangeController &&
        _axisDetails.stateProperties.zoomProgress) {
      _axisDetails.stateProperties.rangeChangedByChart = true;
      _axisDetails.setRangeControllerValues(this);
    }
  }
  _axisDetails.setZoomValuesFromRangeController();
}