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 (_axisDetails._categoryAxis.labelPlacement ==
      LabelPlacement.betweenTicks) {
    range.minimum -= 0.5;
    range.maximum += 0.5;
    range.delta = range.maximum - range.minimum;
  }

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

  calculateVisibleRange(
      Size(_axisDetails.rect.width, _axisDetails.rect.height));

  /// Setting range as visible zoomRange
  if ((_axisDetails._categoryAxis.visibleMinimum != null ||
          _axisDetails._categoryAxis.visibleMaximum != null) &&
      (_axisDetails._categoryAxis.visibleMinimum !=
          _axisDetails._categoryAxis.visibleMaximum) &&
      (!_axisDetails.stateProperties.isRedrawByZoomPan)) {
    _axisDetails.stateProperties.isRedrawByZoomPan = false;
    _axisDetails.visibleRange!.minimum = _axisDetails.visibleMinimum ??
        _axisDetails._categoryAxis.visibleMinimum ??
        _axisDetails.actualRange!.minimum;
    _axisDetails.visibleRange!.maximum = _axisDetails.visibleMaximum ??
        _axisDetails._categoryAxis.visibleMaximum ??
        _axisDetails.actualRange!.maximum;
    if (_axisDetails._categoryAxis.labelPlacement ==
        LabelPlacement.betweenTicks) {
      _axisDetails.visibleRange!.minimum =
          _axisDetails._categoryAxis.visibleMinimum != null
              ? (_axisDetails.visibleMinimum ??
                      _axisDetails._categoryAxis.visibleMinimum!) -
                  0.5
              : _axisDetails.visibleRange!.minimum;
      _axisDetails.visibleRange!.maximum =
          _axisDetails._categoryAxis.visibleMaximum != null
              ? (_axisDetails.visibleMaximum ??
                      _axisDetails._categoryAxis.visibleMaximum!) +
                  0.5
              : _axisDetails.visibleRange!.maximum;
    }
    _axisDetails.visibleRange!.delta = _axisDetails.visibleRange!.maximum -
        _axisDetails.visibleRange!.minimum;
    _axisDetails.visibleRange!.interval = interval == null
        ? calculateInterval(_axisDetails.visibleRange!, _axisDetails.axisSize)
        : _axisDetails.visibleRange!.interval;
    _axisDetails.zoomFactor =
        _axisDetails.visibleRange!.delta / (range.delta);
    _axisDetails.zoomPosition = (_axisDetails.visibleRange!.minimum -
            _axisDetails.actualRange!.minimum) /
        range.delta;
  }
  if (_axisDetails.chart.onActualRangeChanged != null) {
    rangeChangedArgs = ActualRangeChangedArgs(
        _axisDetails.name!,
        _axisDetails._categoryAxis,
        range.minimum,
        range.maximum,
        range.interval,
        _axisDetails.orientation!);
    rangeChangedArgs.visibleMin = _axisDetails.visibleRange!.minimum;
    rangeChangedArgs.visibleMax = _axisDetails.visibleRange!.maximum;
    rangeChangedArgs.visibleInterval = _axisDetails.visibleRange!.interval;
    _axisDetails.chart.onActualRangeChanged!(rangeChangedArgs);
    _axisDetails.visibleRange!.minimum = rangeChangedArgs.visibleMin;
    _axisDetails.visibleRange!.maximum = rangeChangedArgs.visibleMax;
    _axisDetails.visibleRange!.delta = _axisDetails.visibleRange!.maximum -
        _axisDetails.visibleRange!.minimum;
    _axisDetails.visibleRange!.interval = rangeChangedArgs.visibleInterval;
    _axisDetails.zoomFactor =
        _axisDetails.visibleRange!.delta / (range.delta);
    _axisDetails.zoomPosition = (_axisDetails.visibleRange!.minimum -
            _axisDetails.actualRange!.minimum) /
        range.delta;
  }
}