configureDomainAxes method

  1. @override
void configureDomainAxes(
  1. List<MutableSeries<D>> seriesList
)

Adds the domain values for the given series to the chart's domain axis.

Implementation

@override
void configureDomainAxes(List<MutableSeries<D>> seriesList) {
  for (final series in seriesList) {
    if (series.data.isEmpty) {
      continue;
    }

    final domainAxis = series.getAttr(domainAxisKey);
    final domainFn = series.domainFn;
    final domainLowerBoundFn = series.domainLowerBoundFn;
    final domainUpperBoundFn = series.domainUpperBoundFn;

    if (domainAxis == null) {
      continue;
    }

    if (renderingVertically) {
      for (var i = 0; i < series.data.length; i++) {
        domainAxis.addDomainValue(domainFn(i)!);

        if (domainLowerBoundFn != null && domainUpperBoundFn != null) {
          final domainLowerBound = domainLowerBoundFn(i);
          final domainUpperBound = domainUpperBoundFn(i);
          if (domainLowerBound != null && domainUpperBound != null) {
            domainAxis
              ..addDomainValue(domainLowerBound)
              ..addDomainValue(domainUpperBound);
          }
        }
      }
    } else {
      // When rendering horizontally, domains are displayed from top to bottom
      // in order to match visual display in legend.
      for (var i = series.data.length - 1; i >= 0; i--) {
        domainAxis.addDomainValue(domainFn(i)!);

        if (domainLowerBoundFn != null && domainUpperBoundFn != null) {
          final domainLowerBound = domainLowerBoundFn(i);
          final domainUpperBound = domainUpperBoundFn(i);
          if (domainLowerBound != null && domainUpperBound != null) {
            domainAxis
              ..addDomainValue(domainLowerBound)
              ..addDomainValue(domainUpperBound);
          }
        }
      }
    }
  }
}