zoomToSelection method

ChartArtifactResult<void> zoomToSelection({
  1. double paddingFraction = 0.08,
})

Fits the Cartesian viewport to the current durable selection.

paddingFraction is applied independently to the selected X and Y spans. Single-point selections receive a stable viewport-relative minimum span.

Implementation

ChartArtifactResult<void> zoomToSelection({double paddingFraction = 0.08}) {
  if (!paddingFraction.isFinite || paddingFraction < 0) {
    return ChartArtifactFailure(
      error: const ChartArtifactError(
        code: ChartArtifactDiagnosticCodes.invalidArtifact,
        message: 'Selection zoom padding must be finite and non-negative.',
      ),
    );
  }
  final handler = _zoomToSelectionHandler;
  if (handler == null) return _pointCommandDetachedFailure();
  return handler(paddingFraction);
}