computeNonEmptyYValues method

  1. @override
void computeNonEmptyYValues()
override

Implementation

@override
void computeNonEmptyYValues() {
  // Swapping high and low values is necessary before invoking
  // _populateTrendlineDataSource() to render trendline and
  // spline range series based on nonEmptyHighValues and nonEmptyLowValues.
  for (int i = 0; i < dataCount; i++) {
    num high = highValues[i];
    num low = lowValues[i];
    if (low > high) {
      final num temp = high;
      high = low;
      low = temp;
      highValues[i] = high;
      lowValues[i] = low;
    }
  }

  if (emptyPointSettings.mode == EmptyPointMode.gap ||
      emptyPointSettings.mode == EmptyPointMode.drop) {
    final List<num> highValuesCopy = <num>[...highValues];
    final List<num> lowValuesCopy = <num>[...lowValues];
    nonEmptyHighValues = highValuesCopy;
    nonEmptyLowValues = lowValuesCopy;
    for (int i = 0; i < dataCount; i++) {
      if (i == 0 && highValues[i].isNaN) {
        nonEmptyHighValues[i] = 0;
      } else if (i > 0 && highValues[i].isNaN) {
        nonEmptyHighValues[i] = nonEmptyHighValues[i - 1];
      }

      if (i == 0 && lowValues[i].isNaN) {
        nonEmptyLowValues[i] = 0;
      } else if (i > 0 && lowValues[i].isNaN) {
        nonEmptyLowValues[i] = nonEmptyLowValues[i - 1];
      }
    }
  } else {
    nonEmptyHighValues = highValues;
    nonEmptyLowValues = lowValues;
  }
}