selectionRows method
The marks a tooltip lists for the selection: color, name and value.
Implementation
List<(Color, String, double)> selectionRows() {
final sel = selection;
if (sel == null || sel.index >= count) return const [];
final row = rows[sel.index];
final out = <(Color, String, double)>[];
var named = false;
final seen = <(int, String)>{};
for (var p = 0; p < spec.panes.length; p++) {
final marks = spec.panes[p].marks;
for (var k = 0; k < marks.length; k++) {
if (sel.mark != null && (sel.pane != p || sel.mark != k)) continue;
final m = marks[k];
// An area and the line along its top are one thing to read: the line.
if (sel.mark == null && m.type == 'area' && marks.any((o) => o.type == 'line' && o.valueField == m.valueField)) continue;
if (sel.mark == null && !seen.add((p, m.valueField))) continue;
if (row[m.valueField] case final num v when v.isFinite) {
out.add((markColor(m, sel.index), m.label, v.toDouble()));
named = named || m.name.isNotEmpty;
}
}
}
// One mark with no name: its value needs no name beside it (its field
// is no word to read).
if (out.length == 1 && !named) return [(out.single.$1, '', out.single.$3)];
return out;
}