drawTocoLine method

void drawTocoLine(
  1. Canvas canvas,
  2. List<int> list,
  3. Paint lineStyle
)

Draws data points and connecting lines for TOCO measurements. canvas is the canvas to draw on. list is the list of TOCO values. lineStyle is the paint style for the line.

Implementation

void drawTocoLine(Canvas canvas, List<int> list, Paint lineStyle) {
  if (list.isEmpty) {
    return;
  }

  double startX, startY, stopX = 0, stopY = 0;
  int startData, stopData = 0;

  int i = mOffset;
  stopX = getScreenXToco(i);
  stopY = getYValueFromToco(list[i]);
  for (; i < list.length - 1 && i < (mOffset + pointsPerPage); i++) {
    startData = stopData;
    stopData = list[i];

    startX = stopX;
    startY = stopY;

    stopX = getScreenXToco(i);
    stopY = getYValueFromToco(list[i]); // getScreenY(stopData);

    if (i < 1) continue;
    if ((startData - stopData).abs() > 80) {
      continue;
    }
    /*if (Math.abs(startData - stopData) > 150) {
              continue;
          }*/

    // a. If the value is 0, it is not drawn
    // b. If the results of the two values before and after are different by more than 30, they are not connected.

    canvas.drawLine(Offset(startX, startY), Offset(stopX, stopY), lineStyle);
  }
}