onCompute method

  1. @override
void onCompute(
  1. Size size
)
override

获取画布宽度和高度 计算当前屏内相对转换后的X轴位置 根据X轴位置,计算屏内起始和结束展示数据的索引 计算最大值和最小值

Implementation

@override
void onCompute(Size size) {
  super.onCompute(size);
  if (getValues().isNotEmpty) {
    List<double> difs =
        values.map((e) => e.dif!).toList().sublist(startIndex, endIndex);
    List<double> deas =
        values.map((e) => e.dea!).toList().sublist(startIndex, endIndex);
    double minDif = difs.reduce(math.min);
    double minDea = deas.reduce(math.min);
    double maxDif = difs.reduce(math.max);
    double maxDea = deas.reduce(math.max);
    minValue = [minDif, minDea, minValue].reduce(math.min);
    maxValue = [maxDif, maxDea, maxValue].reduce(math.max);

    ratio = zeroLineY / math.max(minValue.abs(), maxValue.abs());
  }
}