percentBase method

double? percentBase(
  1. int pane
)

The value a percent scale measures from: the first row in view's close (or y) of the pane's first mark.

Implementation

double? percentBase(int pane) {
  final marks = spec.panes[pane].marks;
  if (marks.isEmpty) return null;
  final field = marks.first.type == 'candle' ? marks.first.close : marks.first.y;
  final (first, last) = visible;
  for (var i = first; i <= last; i++) {
    if (rows[i][field] case final num v when v != 0) return v.toDouble();
  }
  return null;
}