setData method

  1. @override
void setData(
  1. int index,
  2. ChartSegment segment
)
override

Implementation

@override
void setData(int index, ChartSegment segment) {
  super.setData(index, segment);

  final BoxPlotQuartileValues boxPlotValues = BoxPlotQuartileValues();
  _findBoxPlotValues(yValues[index], boxPlotMode, boxPlotValues);

  final num minimum = boxPlotValues.minimum ?? double.nan;
  final num maximum = boxPlotValues.maximum ?? double.nan;
  final num lowerQuartile = boxPlotValues.lowerQuartile ?? double.nan;
  final num upperQuartile = boxPlotValues.upperQuartile ?? double.nan;
  final num mean = boxPlotValues.average ?? double.nan;
  final num median = boxPlotValues.median ?? double.nan;

  maximumValues.add(maximum);
  minimumValues.add(minimum);
  lowerValues.add(lowerQuartile);
  upperValues.add(upperQuartile);
  meanValues.add(mean);
  medianValues.add(median);

  if (boxPlotValues.outliers != null) {
    if (boxPlotValues.outliers!.isEmpty) {
      outliersValues.add(<num>[double.nan]);
    } else {
      outliersValues.add(boxPlotValues.outliers!);
    }
  }

  segment as BoxAndWhiskerSegment<T, D>
    ..series = this
    ..x = xValues[index]
    .._minimum = minimum
    .._maximum = maximum
    .._lowerQuartile = lowerQuartile
    .._upperQuartile = upperQuartile
    .._median = median
    .._mean = mean
    ..outliers = boxPlotValues.outliers;
}