centerViewTo method

void centerViewTo(
  1. double xValue,
  2. double yValue,
  3. AxisDependency axis
)

This will move the center of the current viewport to the specified x and y value. call state?.setStateIfNotDispose() to invalidate

@param xValue @param yValue @param axis - which axis should be used as a reference for the y axis

Implementation

void centerViewTo(double xValue, double yValue, AxisDependency axis) {
  double yInView = getAxisRange(axis) / viewPortHandler!.getScaleY();
  double xInView = xAxis!.axisRange / viewPortHandler!.getScaleX();
  List<double> pts = List.empty(growable: true);
  pts.add(xValue - xInView / 2);
  pts.add(yValue + yInView / 2);
  painter?.getTransformer(axis)?.pointValuesToPixel(pts);
  viewPortHandler!.centerViewPort(pts);
}