calculateVisibleRange method
Calculates the visible range for an axis in chart.
Implementation
@override
void calculateVisibleRange(Size availableSize) {
final ChartAxisRendererDetails axisDetails =
AxisHelper.getAxisRendererDetails(this);
final CartesianStateProperties stateProperties =
axisDetails.stateProperties;
axisDetails.setOldRangeFromRangeController();
axisDetails.visibleRange = stateProperties.rangeChangeBySlider &&
axisDetails.rangeMinimum != null &&
axisDetails.rangeMaximum != null
? VisibleRange(axisDetails.rangeMinimum, axisDetails.rangeMaximum)
: VisibleRange(
axisDetails.actualRange!.minimum, axisDetails.actualRange!.maximum);
axisDetails.visibleRange!.delta = axisDetails.actualRange!.delta;
axisDetails.visibleRange!.interval = axisDetails.actualRange!.interval;
bool canAutoScroll = false;
if (axisDetails.axis.autoScrollingDelta != null &&
axisDetails.axis.autoScrollingDelta! > 0 &&
!stateProperties.isRedrawByZoomPan) {
canAutoScroll = true;
axisDetails.updateAutoScrollingDelta(
axisDetails.axis.autoScrollingDelta!, this);
}
if ((!canAutoScroll || (stateProperties.zoomedState ?? false)) &&
!(stateProperties.rangeChangeBySlider &&
!stateProperties.canSetRangeController)) {
axisDetails.setZoomFactorAndPosition(
this, stateProperties.zoomedAxisRendererStates);
}
if (axisDetails.zoomFactor < 1 ||
axisDetails.zoomPosition > 0 ||
(axisDetails.axis.rangeController != null &&
!stateProperties.renderingDetails.initialRender!) &&
!(stateProperties.rangeChangeBySlider ||
!stateProperties.canSetRangeController)) {
stateProperties.zoomProgress = true;
axisDetails.calculateZoomRange(this, availableSize);
axisDetails.visibleRange!.interval = !canAutoScroll &&
axisDetails.axis.enableAutoIntervalOnZooming &&
stateProperties.zoomProgress
? calculateInterval(axisDetails.visibleRange!, axisDetails.axisSize)
: axisDetails.visibleRange!.interval;
if (axisDetails.axis.rangeController != null &&
stateProperties.isRedrawByZoomPan &&
stateProperties.canSetRangeController &&
stateProperties.zoomProgress) {
stateProperties.rangeChangedByChart = true;
axisDetails.setRangeControllerValues(this);
}
}
axisDetails.setZoomValuesFromRangeController();
}