createTicks method

List<Tick<DateTime>> createTicks(
  1. List<DateTime> domainValues, {
  2. required ChartContext? context,
  3. required GraphicsFactory graphicsFactory,
  4. required MutableScale<DateTime> scale,
  5. required TickFormatter<DateTime> formatter,
  6. required Map<DateTime, String> formatterValueCache,
  7. required TickDrawStrategy<DateTime> tickDrawStrategy,
  8. num? stepSize,
})
inherited

Create ticks from domainValues.

Implementation

List<Tick<D>> createTicks(
  List<D> domainValues, {
  required ChartContext? context,
  required GraphicsFactory graphicsFactory,
  required MutableScale<D> scale,
  required TickFormatter<D> formatter,
  required Map<D, String> formatterValueCache,
  required TickDrawStrategy<D> tickDrawStrategy,
  num? stepSize,
}) {
  final ticks = <Tick<D>>[];
  final labels =
      formatter.format(domainValues, formatterValueCache, stepSize: stepSize);

  for (var i = 0; i < domainValues.length; i++) {
    final value = domainValues[i];
    final tick = Tick(
      value: value,
      textElement: graphicsFactory.createTextElement(labels[i]),
      locationPx: scale[value]?.toDouble(),
    );

    ticks.add(tick);
  }

  // Allow draw strategy to decorate the ticks.
  tickDrawStrategy.decorateTicks(ticks);

  return ticks;
}