zoomByFactor method

void zoomByFactor(
  1. double zoomFactor
)

Changes the zoom level using zoom factor.

Here, you can pass the zoom factor of an axis to magnify the plot area. The value ranges from 0 to 1.

Implementation

void zoomByFactor(double zoomFactor) {
  final RenderBehaviorArea? parent = parentBox as RenderBehaviorArea?;
  if (parent == null) {
    return;
  }

  parent.hideInteractiveTooltip();
  final RenderCartesianAxes? cartesianAxes = parent.cartesianAxes;
  if (cartesianAxes == null) {
    return;
  }
  _isZoomIn = false;
  _isZoomOut = true;
  // TODO(YuvarajG): Need to have variable to notify zooming inprogress
  // _stateProperties.zoomProgress = true;
  RenderChartAxis? child = cartesianAxes.firstChild;
  if (zoomFactor.clamp(0.0, 1.0) == zoomFactor) {
    while (child != null) {
      if ((child.isVertical && zoomMode != ZoomMode.x) ||
          (!child.isVertical && zoomMode != ZoomMode.y)) {
        child.controller.zoomFactor = zoomFactor;
        if (parent.onZooming != null) {
          _bindZoomEvent(child, parent.onZooming!);
        }
      }
      final CartesianAxesParentData childParentData =
          child.parentData! as CartesianAxesParentData;
      child = childParentData.nextSibling;
    }
    (parentBox as RenderBehaviorArea?)?.invalidate();
  }
}