calculateMaxMin method

List<double> calculateMaxMin(
  1. List<ChartBean>? chatBeans
)

计算极值 最大值,最小值

Implementation

List<double> calculateMaxMin(List<ChartBean>? chatBeans) {
  if (chatBeans == null || chatBeans.length == 0) return [0, 0];
  double max = 0.0, min = 0.0;
  for (ChartBean bean in chatBeans) {
    if (max < bean.y) {
      max = bean.y;
    }
    if (min > bean.y) {
      min = bean.y;
    }
  }
  return [max, min];
}