applyRangePadding method

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

Applies range padding to auto, normal, additional, round, and none types.

Implementation

@override
void applyRangePadding(VisibleRange range, num? interval) {
  ActualRangeChangedArgs rangeChangedArgs;
  final NumericAxisDetails axisDetails =
      AxisHelper.getAxisRendererDetails(this) as NumericAxisDetails;
  if (!(axisDetails.numericAxis.minimum != null &&
      axisDetails.numericAxis.maximum != null)) {
    ///Calculating range padding
    axisDetails.applyRangePaddings(
        this, axisDetails.stateProperties, range, interval!);
  }

  calculateVisibleRange(axisDetails.axisSize);

  /// Setting range as visible zoomRange
  if ((axisDetails.numericAxis.visibleMinimum != null ||
          axisDetails.numericAxis.visibleMaximum != null) &&
      (axisDetails.numericAxis.visibleMinimum !=
          axisDetails.numericAxis.visibleMaximum) &&
      (!axisDetails.stateProperties.isRedrawByZoomPan)) {
    axisDetails.stateProperties.isRedrawByZoomPan = false;
    axisDetails.visibleRange!.minimum = axisDetails.visibleMinimum ??
        axisDetails.numericAxis.visibleMinimum ??
        axisDetails.actualRange!.minimum;
    axisDetails.visibleRange!.maximum = axisDetails.visibleMaximum ??
        axisDetails.numericAxis.visibleMaximum ??
        axisDetails.actualRange!.maximum;
    axisDetails.visibleRange!.delta =
        axisDetails.visibleRange!.maximum - axisDetails.visibleRange!.minimum;
    axisDetails.visibleRange!.interval = interval == null
        ? axisDetails.calculateNumericNiceInterval(
            this,
            axisDetails.visibleRange!.maximum -
                axisDetails.visibleRange!.minimum,
            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.numericAxis,
        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;
  }
}