panToDirection method

void panToDirection(
  1. String direction
)

Pans the plot area for given left, right, top, and bottom directions.

To perform this action, the plot area needs to be in zoomed state.

Implementation

void panToDirection(String direction) {
  final RenderBehaviorArea? parent = parentBox as RenderBehaviorArea?;
  if (parent == null) {
    return;
  }

  parent.hideInteractiveTooltip();
  final RenderCartesianAxes? cartesianAxes = parent.cartesianAxes;
  if (cartesianAxes == null) {
    return;
  }
  direction = direction.toLowerCase();
  RenderChartAxis? child = cartesianAxes.firstChild;
  while (child != null) {
    if (child.isVertical) {
      if (direction == 'bottom') {
        child.controller.zoomPosition = (child.controller.zoomPosition > 0 &&
                child.controller.zoomPosition <= 1.0)
            ? child.controller.zoomPosition - 0.1
            : child.controller.zoomPosition;
        child.controller.zoomPosition = child.controller.zoomPosition < 0.0
            ? 0.0
            : child.controller.zoomPosition;
      }
      if (direction == 'top') {
        child.controller.zoomPosition = (child.controller.zoomPosition >= 0 &&
                child.controller.zoomPosition < 1)
            ? child.controller.zoomPosition + 0.1
            : child.controller.zoomPosition;
        child.controller.zoomPosition = child.controller.zoomPosition > 1.0
            ? 1.0
            : child.controller.zoomPosition;
      }
    } else {
      if (direction == 'left') {
        child.controller.zoomPosition = (child.controller.zoomPosition > 0 &&
                child.controller.zoomPosition <= 1.0)
            ? child.controller.zoomPosition - 0.1
            : child.controller.zoomPosition;
        child.controller.zoomPosition = child.controller.zoomPosition < 0.0
            ? 0.0
            : child.controller.zoomPosition;
      }
      if (direction == 'right') {
        child.controller.zoomPosition = (child.controller.zoomPosition >= 0 &&
                child.controller.zoomPosition < 1)
            ? child.controller.zoomPosition + 0.1
            : child.controller.zoomPosition;
        child.controller.zoomPosition = child.controller.zoomPosition > 1.0
            ? 1.0
            : child.controller.zoomPosition;
      }
    }
    if (parent.onZooming != null) {
      _bindZoomEvent(child, parent.onZooming!);
    }
    final CartesianAxesParentData childParentData =
        child.parentData! as CartesianAxesParentData;
    child = childParentData.nextSibling;
  }
  parent.invalidate();
}