formatTick method

String formatTick(
  1. double value
)

Format a tick value as a display string.

Implementation

String formatTick(double value) {
  if (tickFormatter != null) return tickFormatter!(value);
  switch (scaleType) {
    case AxisScaleType.percent:
      return '${value.toStringAsFixed(0)}%';
    case AxisScaleType.log:
      // Display as power: 10^n
      return _formatLogTick(value, logBase);
    case AxisScaleType.category:
      final cats = categories ?? const [];
      final idx = value.round();
      return (idx >= 0 && idx < cats.length) ? cats[idx] : '';
    case AxisScaleType.time:
      if (timeFormatter != null) {
        return timeFormatter!(
          DateTime.fromMillisecondsSinceEpoch(value.round()),
        );
      }
      return _formatTimeTick(value);
    default:
      return _formatNumber(value);
  }
}