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) {
  _chartState!._canSetRangeController = true;
  final SfCartesianChartState chartState = _chartState!;
  final SfCartesianChart chart = chartState._chart;
  final ZoomPanBehaviorRenderer zoomPanBehaviorRenderer =
      chartState._zoomPanBehaviorRenderer;
  ChartAxisRenderer axisRenderer;
  direction = direction.toLowerCase();
  for (int axisIndex = 0;
      axisIndex < chartState._chartAxis._axisRenderersCollection.length;
      axisIndex++) {
    axisRenderer = chartState._chartAxis._axisRenderersCollection[axisIndex];
    if (axisRenderer._orientation == AxisOrientation.horizontal) {
      if (direction == 'left') {
        axisRenderer._zoomPosition = (axisRenderer._zoomPosition > 0 &&
                axisRenderer._zoomPosition <= 0.9)
            ? axisRenderer._zoomPosition - 0.1
            : axisRenderer._zoomPosition;
        axisRenderer._zoomPosition = axisRenderer._zoomPosition < 0.0
            ? 0.0
            : axisRenderer._zoomPosition;
      }
      if (direction == 'right') {
        axisRenderer._zoomPosition = (axisRenderer._zoomPosition >= 0 &&
                axisRenderer._zoomPosition < 1)
            ? axisRenderer._zoomPosition + 0.1
            : axisRenderer._zoomPosition;
        axisRenderer._zoomPosition = axisRenderer._zoomPosition > 1.0
            ? 1.0
            : axisRenderer._zoomPosition;
      }
    } else {
      if (direction == 'bottom') {
        axisRenderer._zoomPosition = (axisRenderer._zoomPosition > 0 &&
                axisRenderer._zoomPosition <= 0.9)
            ? axisRenderer._zoomPosition - 0.1
            : axisRenderer._zoomPosition;
        axisRenderer._zoomPosition = axisRenderer._zoomPosition < 0.0
            ? 0.0
            : axisRenderer._zoomPosition;
      }
      if (direction == 'top') {
        axisRenderer._zoomPosition = (axisRenderer._zoomPosition >= 0 &&
                axisRenderer._zoomPosition < 1)
            ? axisRenderer._zoomPosition + 0.1
            : axisRenderer._zoomPosition;
        axisRenderer._zoomPosition = axisRenderer._zoomPosition > 1.0
            ? 1.0
            : axisRenderer._zoomPosition;
      }
    }
    if (chart.onZooming != null) {
      ZoomPanArgs? zoomingArgs;
      _bindZoomEvent(chart, axisRenderer, zoomingArgs, chart.onZooming!);
    }
  }
  zoomPanBehaviorRenderer._createZoomState();
}