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) {
  _stateProperties.canSetRangeController = true;
  final SfCartesianChart chart = _stateProperties.chart;
  ChartAxisRendererDetails axisDetails;
  direction = direction.toLowerCase();
  for (int axisIndex = 0;
      axisIndex < _stateProperties.chartAxis.axisRenderersCollection.length;
      axisIndex++) {
    axisDetails = AxisHelper.getAxisRendererDetails(
        _stateProperties.chartAxis.axisRenderersCollection[axisIndex]);
    if (axisDetails.orientation == AxisOrientation.horizontal) {
      if (direction == 'left') {
        axisDetails.zoomPosition =
            (axisDetails.zoomPosition > 0 && axisDetails.zoomPosition <= 0.9)
                ? axisDetails.zoomPosition - 0.1
                : axisDetails.zoomPosition;
        axisDetails.zoomPosition =
            axisDetails.zoomPosition < 0.0 ? 0.0 : axisDetails.zoomPosition;
      }
      if (direction == 'right') {
        axisDetails.zoomPosition =
            (axisDetails.zoomPosition >= 0 && axisDetails.zoomPosition < 1)
                ? axisDetails.zoomPosition + 0.1
                : axisDetails.zoomPosition;
        axisDetails.zoomPosition =
            axisDetails.zoomPosition > 1.0 ? 1.0 : axisDetails.zoomPosition;
      }
    } else {
      if (direction == 'bottom') {
        axisDetails.zoomPosition =
            (axisDetails.zoomPosition > 0 && axisDetails.zoomPosition <= 0.9)
                ? axisDetails.zoomPosition - 0.1
                : axisDetails.zoomPosition;
        axisDetails.zoomPosition =
            axisDetails.zoomPosition < 0.0 ? 0.0 : axisDetails.zoomPosition;
      }
      if (direction == 'top') {
        axisDetails.zoomPosition =
            (axisDetails.zoomPosition >= 0 && axisDetails.zoomPosition < 1)
                ? axisDetails.zoomPosition + 0.1
                : axisDetails.zoomPosition;
        axisDetails.zoomPosition =
            axisDetails.zoomPosition > 1.0 ? 1.0 : axisDetails.zoomPosition;
      }
    }
    if (chart.onZooming != null) {
      bindZoomEvent(chart, axisDetails, chart.onZooming!);
    }
  }
  _stateProperties.zoomPanBehaviorRenderer._zoomingBehaviorDetails
      .createZoomState();
}