updateOffset method

void updateOffset(
  1. double offset
)

Implementation

void updateOffset(double offset) {
  final start = offset ~/ itemWidth.value;
  final end = ((offset + maxWidth) / itemWidth.value).ceil();

  if (this.start.value == start && this.end.value == end) return;

  this.start.value = start;
  this.end.value = end;

  var high = 0.0;
  var low = double.infinity;
  var maxVolume = 0.0;
  for (var i = start; i < end; i += 1) {
    final item = data[i];
    if (item.high > high) high = item.high;
    if (item.low < low) low = item.low;
    if (item.volume > maxVolume) maxVolume = item.volume;
  }
  this.high.value = high;
  this.low.value = low;
  this.maxVolume.value = maxVolume;
}