DateTimeTickFormatter constructor

DateTimeTickFormatter(
  1. DateTimeFactory dateTimeFactory, {
  2. Map<int, TimeTickFormatter>? overrides,
})

Creates a DateTimeTickFormatter that works well with time tick provider classes.

The default formatter makes assumptions on border cases that time tick providers will still provide ticks that make sense. Example: Tick provider does not provide ticks with 23 hour intervals. For custom tick providers where these assumptions are not correct, please create a custom TickFormatter.

Implementation

factory DateTimeTickFormatter(DateTimeFactory dateTimeFactory,
    {Map<int, TimeTickFormatter>? overrides}) {
  final map = <int, TimeTickFormatter>{
    minute: TimeTickFormatterImpl(
        dateTimeFactory: dateTimeFactory,
        simpleFormat: 'mm',
        transitionFormat: 'h mm',
        transitionField: CalendarField.hourOfDay),
    hour: HourTickFormatter(
        dateTimeFactory: dateTimeFactory,
        simpleFormat: 'h',
        transitionFormat: 'MMM d ha',
        noonFormat: 'ha'),
    23 * hour: TimeTickFormatterImpl(
        dateTimeFactory: dateTimeFactory,
        simpleFormat: 'd',
        transitionFormat: 'MMM d',
        transitionField: CalendarField.month),
    28 * day: TimeTickFormatterImpl(
        dateTimeFactory: dateTimeFactory,
        simpleFormat: 'MMM',
        transitionFormat: 'MMM yyyy',
        transitionField: CalendarField.year),
    364 * day: TimeTickFormatterImpl(
        dateTimeFactory: dateTimeFactory,
        simpleFormat: 'yyyy',
        transitionFormat: 'yyyy',
        transitionField: CalendarField.year),
  };

  // Allow the user to override some of the defaults.
  if (overrides != null) {
    map.addAll(overrides);
  }

  return DateTimeTickFormatter._internal(map);
}