onDragUpdate method
Implementation
@protected
bool onDragUpdate(Point<double> localPosition, double scale) {
if (!_isPanning || _lastPosition == null || _chart == null) {
return false;
}
// Pinch gestures should be handled by the [PanAndZoomBehavior].
if (scale != 1.0) {
_isPanning = false;
return false;
}
// Update the domain axis's viewport translate to pan the chart.
final domainAxis = _chart!.domainAxis;
if (domainAxis == null) {
return false;
}
// This is set during onDragUpdate and NOT onDragStart because we don't yet
// know during onDragStart whether pan/zoom behavior is panning or zooming.
// During panning, domain tick provider set to generate ticks with locked
// steps.
_domainAxisTickProvider.mode = PanningTickProviderMode.stepSizeLocked;
final domainScalingFactor = domainAxis.viewportScalingFactor;
var domainChange = 0.0;
if (domainAxis.isVertical) {
domainChange =
domainAxis.viewportTranslatePx + localPosition.y - _lastPosition!.y;
} else {
domainChange =
domainAxis.viewportTranslatePx + localPosition.x - _lastPosition!.x;
}
final chart = this.chart!;
domainAxis.setViewportSettings(domainScalingFactor, domainChange,
drawAreaWidth: chart.drawAreaBounds.width,
drawAreaHeight: chart.drawAreaBounds.height);
_lastPosition = localPosition;
chart.redraw(skipAnimation: true, skipLayout: true);
return true;
}