generateMinor method

  1. @override
List<double> generateMinor(
  1. ChartTickContext context,
  2. List<ChartTick> major
)
override

Returns the values of the minor ticks for context, in ascending order: marks without a label between the major ticks, which are what generate returned for the same context. The default is none.

An axis draws a short mark at each and a grid can draw a fainter line.

Implementation

@override
List<double> generateMinor(ChartTickContext context, List<ChartTick> major) {
  final double span = context.max - context.min;
  if (minorCount <= 0 || !(span > 0) || !span.isFinite) return const <double>[];
  final int parts = minorCount + 1;
  final double step = ChartTicks.niceStep(span / context.targetCount(spacing));
  final double minor = step / parts;
  if (minor * context.extent / span < ChartTicks._minorSpacing) return const <double>[];
  final List<double> values = <double>[];
  // Counted from the tick at or below the window, to avoid accumulating
  // floating point error.
  final double base = (context.min / step).floorToDouble() * step;
  for (int i = 1; i < 100000; i++) {
    final double value = base + i * minor;
    if (value > context.max + minor * 1e-9) break;
    if (i % parts == 0 || value < context.min - minor * 1e-9) continue;
    values.add((value / minor).roundToDouble() * minor);
  }
  return values;
}