getDomainPaddingForMarkers function

({double end, double start}) getDomainPaddingForMarkers(
  1. double minVal,
  2. double maxVal, {
  3. FluentAxisScaleType? scaleType,
  4. double? userMinVal,
  5. double? userMaxVal,
})

How much domain to add at each end of [minVal, maxVal] so that markers drawn at the extremes are not clipped.

Ports getDomainPaddingForMarkers (utilities.ts:2232-2266). A user-supplied bound that already sits further out than a tenth of the range suppresses the padding on that side, so an explicit axis minimum does not get padded twice. The log branch is deliberately asymmetric — end is the raw maximum rather than a delta — and is ported as written.

Implementation

({double start, double end}) getDomainPaddingForMarkers(
  double minVal,
  double maxVal, {
  FluentAxisScaleType? scaleType,
  double? userMinVal,
  double? userMaxVal,
}) {
  if (scaleType == FluentAxisScaleType.log) {
    // 0.5 is the log-scale start factor at `utilities.ts:2241`.
    return (start: minVal * 0.5, end: maxVal);
  }
  // 0.1 is the ten-per-cent padding at `utilities.ts:2251`.
  final rangePadding = (maxVal - minVal) * 0.1;
  // `utilities.ts:2254-2257`: an explicit bound counts as already padded when it
  // sits less than the padding away from the data.
  final satisfiedAtMin =
      userMinVal != null &&
      rangePadding > (minVal - math.min(minVal, userMinVal)).abs();
  final satisfiedAtMax =
      userMaxVal != null &&
      rangePadding > (maxVal - math.max(maxVal, userMaxVal)).abs();
  return (
    start: satisfiedAtMin ? 0 : rangePadding,
    end: satisfiedAtMax ? 0 : rangePadding,
  );
}