xTickLabel method
A tick's label: its own unit, or the larger one it also starts (a year at January, a month at its first day).
Implementation
String xTickLabel(int index) {
if (spec.x.ticks != 'calendar') return xLabel(index);
if (index < 0 || index >= count) return '';
final t = _time(index);
if (t == null) return xLabel(index);
final before = index > 0 ? _time(index - 1) : null;
bool starts(int level) => before != null && _bucket(t, level) != _bucket(before, level);
final pattern = switch (_tickLevel) {
0 => 'yyyy',
1 => starts(0) ? 'yyyy' : 'MMM',
2 => starts(1) ? 'MMM' : 'd',
_ => starts(2) ? 'd' : 'HH:mm',
};
return xLabel(index, pattern);
}