rangeBetween static method
The inclusive column range spanned by a drag from pixel x startX to
endX, with every mark inside it. Returns null for an empty scene.
Implementation
static ChartRange? rangeBetween(
ChartScene scene,
double startX,
double endX,
) {
if (scene.isEmpty) return null;
final a = nearestIndexAtX(scene, math.min(startX, endX));
final b = nearestIndexAtX(scene, math.max(startX, endX));
if (a == null || b == null) return null;
final lo = math.min(a, b);
final hi = math.max(a, b);
return ChartRange(
startIndex: lo,
endIndex: hi,
marks: [
for (final m in scene.marks)
if (m.index >= lo && m.index <= hi) m,
],
);
}