calculateVisibleRange method

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

Calculates the visible range for an axis in chart.

Implementation

@override
void calculateVisibleRange(Size availableSize) {
  _setOldRangeFromRangeController();
  _visibleRange = _chartState._rangeChangeBySlider &&
          _rangeMinimum != null &&
          _rangeMaximum != null
      ? _VisibleRange(_rangeMinimum, _rangeMaximum)
      : _VisibleRange(_actualRange!.minimum, _actualRange!.maximum);
  _visibleRange!.delta = _actualRange!.delta;
  _visibleRange!.interval = _actualRange!.interval;
  bool canAutoScroll = false;
  if (_logarithmicAxis.autoScrollingDelta != null &&
      _logarithmicAxis.autoScrollingDelta! > 0 &&
      !_chartState._isRedrawByZoomPan) {
    canAutoScroll = true;
    super._updateAutoScrollingDelta(
        _logarithmicAxis.autoScrollingDelta!, this);
  }
  if (!canAutoScroll &&
      !(_chartState._rangeChangeBySlider &&
          !_chartState._canSetRangeController)) {
    _setZoomFactorAndPosition(this, _chartState._zoomedAxisRendererStates);
  }
  if (_zoomFactor < 1 ||
      _zoomPosition > 0 ||
      (_axis.rangeController != null && !_chartState._initialRender!) &&
          !(_chartState._rangeChangeBySlider ||
              !_chartState._canSetRangeController)) {
    _chartState._zoomProgress = true;
    _calculateZoomRange(this, availableSize);
    _visibleRange!.delta = _visibleRange!.maximum - _visibleRange!.minimum;
    _visibleRange!.interval =
        _axis.enableAutoIntervalOnZooming && _chartState._zoomProgress
            ? calculateLogNiceInterval(_visibleRange!.delta)
            : _visibleRange!.interval;
    _visibleRange!.interval = _visibleRange!.interval.floor() == 0
        ? 1
        : _visibleRange!.interval.floor();
    if (_axis.rangeController != null &&
        _chartState._isRedrawByZoomPan &&
        _chartState._canSetRangeController &&
        _chartState._zoomProgress) {
      _chartState._rangeChangedByChart = true;
      _setRangeControllerValues(this);
    }
  }
  _setZoomValuesFromRangeController();
}