moveViewToAnimated method
This will move the left side of the current viewport to the specified x-value and center the viewport to the y value animated. call state?.setStateIfNotDispose() to invalidate
@param xValue @param yValue @param axis @param duration the duration of the animation in milliseconds
Implementation
void moveViewToAnimated(
double xValue, double yValue, AxisDependency axis, int durationMillis) {
MPPointD bounds = getValuesByTouchPoint(
viewPortHandler!.contentLeft(), viewPortHandler!.contentTop(), axis);
double yInView = getAxisRange(axis) / viewPortHandler!.getScaleY();
yValue = yValue + yInView / 2;
List<double> pts = List.empty(growable: true);
pts.add(xValue);
pts.add(yValue);
double? xOrigin = bounds.x;
double? yOrigin = bounds.y;
ChartAnimator(UpdateListener((x, y) {
pts[0] = xOrigin + (xValue - xOrigin) * x;
pts[1] = yOrigin + (yValue - yOrigin) * y;
painter?.getTransformer(axis)?.pointValuesToPixel(pts);
viewPortHandler!.centerViewPort(pts);
state.setStateIfNotDispose();
})).animateXY1(durationMillis, durationMillis);
MPPointD.recycleInstance2(bounds);
}