applyRangePadding method

  1. @override
void applyRangePadding(
  1. _VisibleRange range,
  2. num? interval
)
override

Applies range padding

Implementation

@override
void applyRangePadding(_VisibleRange range, num? interval) {
  ActualRangeChangedArgs rangeChangedArgs;
  if (_categoryAxis.labelPlacement == LabelPlacement.betweenTicks) {
    range.minimum -= 0.5;
    range.maximum += 0.5;
    range.delta = range.maximum - range.minimum;
  }

  if (!(_categoryAxis.minimum != null && _categoryAxis.maximum != null)) {
    ///Calculating range padding
    _applyRangePadding(this, _chartState, range, interval!);
  }

  calculateVisibleRange(Size(_rect.width, _rect.height));

  /// Setting range as visible zoomRange
  if ((_categoryAxis.visibleMinimum != null ||
          _categoryAxis.visibleMaximum != null) &&
      (_categoryAxis.visibleMinimum != _categoryAxis.visibleMaximum) &&
      (!_chartState._isRedrawByZoomPan)) {
    _chartState._isRedrawByZoomPan = false;
    _visibleRange!.minimum = _visibleMinimum ??
        _categoryAxis.visibleMinimum ??
        _visibleRange!.minimum;
    _visibleRange!.maximum = _visibleMaximum ??
        _categoryAxis.visibleMaximum ??
        _visibleRange!.maximum;
    if (_categoryAxis.labelPlacement == LabelPlacement.betweenTicks) {
      _visibleRange!.minimum = _categoryAxis.visibleMinimum != null
          ? (_visibleMinimum ?? _categoryAxis.visibleMinimum!) - 0.5
          : _visibleRange!.minimum;
      _visibleRange!.maximum = _categoryAxis.visibleMaximum != null
          ? (_visibleMaximum ?? _categoryAxis.visibleMaximum!) + 0.5
          : _visibleRange!.maximum;
    }
    _visibleRange!.delta = _visibleRange!.maximum - _visibleRange!.minimum;
    _visibleRange!.interval = interval == null
        ? calculateInterval(_visibleRange!, _axisSize)
        : _visibleRange!.interval;
    _zoomFactor = _visibleRange!.delta / (range.delta);
    _zoomPosition =
        (_visibleRange!.minimum - _actualRange!.minimum) / range.delta;
  }
  if (_chart.onActualRangeChanged != null) {
    rangeChangedArgs = ActualRangeChangedArgs(_name!, _categoryAxis,
        range.minimum, range.maximum, range.interval, _orientation!);
    rangeChangedArgs.visibleMin = _visibleRange!.minimum;
    rangeChangedArgs.visibleMax = _visibleRange!.maximum;
    rangeChangedArgs.visibleInterval = _visibleRange!.interval;
    _chart.onActualRangeChanged!(rangeChangedArgs);
    _visibleRange!.minimum = rangeChangedArgs.visibleMin;
    _visibleRange!.maximum = rangeChangedArgs.visibleMax;
    _visibleRange!.delta = _visibleRange!.maximum - _visibleRange!.minimum;
    _visibleRange!.interval = rangeChangedArgs.visibleInterval;
    _zoomFactor = _visibleRange!.delta / (range.delta);
    _zoomPosition =
        (_visibleRange!.minimum - _actualRange!.minimum) / range.delta;
  }
}