applyRangePadding method
Applies range padding to auto, normal, additional, round, and none types.
Implementation
@override
void applyRangePadding(_VisibleRange range, num? interval) {
ActualRangeChangedArgs rangeChangedArgs;
if (_dateTimeCategoryAxis.labelPlacement == LabelPlacement.betweenTicks) {
range.minimum -= 0.5;
range.maximum += 0.5;
range.delta = range.maximum - range.minimum;
}
if (_dateTimeCategoryAxis.isVisible &&
!(_dateTimeCategoryAxis.minimum != null &&
_dateTimeCategoryAxis.maximum != null)) {
///Calculating range padding
_applyRangePadding(this, _chartState, range, interval!);
}
calculateVisibleRange(Size(_rect.width, _rect.height));
/// Setting range as visible zoomRange
if ((_dateTimeCategoryAxis.visibleMinimum != null ||
_dateTimeCategoryAxis.visibleMaximum != null) &&
(_dateTimeCategoryAxis.visibleMinimum !=
_dateTimeCategoryAxis.visibleMaximum) &&
_chartState._zoomedAxisRendererStates.isEmpty) {
_visibleRange!.minimum = _visibleMinimum != null
? _getEffectiveRange(
DateTime.fromMillisecondsSinceEpoch(_visibleMinimum!.toInt()),
true)
: _getEffectiveRange(_dateTimeCategoryAxis.visibleMinimum, true) ??
_visibleRange!.minimum;
_visibleRange!.maximum = _visibleMaximum != null
? _getEffectiveRange(
DateTime.fromMillisecondsSinceEpoch(_visibleMaximum!.toInt()),
false)
: _getEffectiveRange(_dateTimeCategoryAxis.visibleMaximum, false) ??
_visibleRange!.maximum;
if (_dateTimeCategoryAxis.labelPlacement == LabelPlacement.betweenTicks) {
_visibleRange!.minimum = _visibleMinimum != null
? _getEffectiveRange(
DateTime.fromMillisecondsSinceEpoch(
_visibleMinimum!.toInt()),
true)! -
0.5
: (_dateTimeCategoryAxis.visibleMinimum != null
? _getEffectiveRange(
_dateTimeCategoryAxis.visibleMinimum, true)! -
0.5
: _visibleRange!.minimum);
_visibleRange!.maximum = _visibleMaximum != null
? _getEffectiveRange(
DateTime.fromMillisecondsSinceEpoch(
_visibleMaximum!.toInt()),
false)! +
0.5
: (_dateTimeCategoryAxis.visibleMaximum != null
? _getEffectiveRange(
_dateTimeCategoryAxis.visibleMaximum, false)! +
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!, _dateTimeCategoryAxis,
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 is DateTime
? _getEffectiveRange(rangeChangedArgs.visibleMin, true)
: rangeChangedArgs.visibleMin;
_visibleRange!.maximum = rangeChangedArgs.visibleMax is DateTime
? _getEffectiveRange(rangeChangedArgs.visibleMax, false)
: rangeChangedArgs.visibleMax;
_visibleRange!.delta = _visibleRange!.maximum - _visibleRange!.minimum;
_visibleRange!.interval = rangeChangedArgs.visibleInterval;
_zoomFactor = _visibleRange!.delta / (range.delta);
_zoomPosition =
(_visibleRange!.minimum - _actualRange!.minimum) / range.delta;
}
}