zoomToSingleAxis method

void zoomToSingleAxis(
  1. ChartAxis axis,
  2. double zoomPosition,
  3. double zoomFactor
)

Change the zoom level of an appropriate axis.

Here, you need to pass axis, zoom factor, zoom position of the zoom level that needs to be modified.

Implementation

void zoomToSingleAxis(
    ChartAxis axis, double zoomPosition, double zoomFactor) {
  final RenderBehaviorArea? parent = parentBox as RenderBehaviorArea?;
  if (parent == null) {
    return;
  }

  parent.hideInteractiveTooltip();
  final RenderChartAxis? axisDetails = axis.name != null
      ? parent.axisFromName(axis.name)
      : parent.axisFromObject(axis);

  if (axisDetails != null) {
    axisDetails.controller.zoomFactor = max(zoomFactor, maximumZoomLevel);
    axisDetails.controller.zoomPosition = zoomPosition;
  }
  parent.invalidate();
}