code: function paintField(ctx, location, field, range) {
    let count;
    let min = Number.MAX_VALUE;
    let max = Number.MIN_VALUE;
  
    const xOffset = location.x;
    const yOffset = location.y;
    const width = location.width;
    const height = location.height;
    const values = field.data;
    const size = values.length;
    const xValues = new Uint16Array(size);
  
    // Compute xValues and min/max
    count = size;
    while (count) {
      count -= 1;
      const value = values[count];
      min = Math.min(min, value);
      max = Math.max(max, value);
      xValues[count] = xOffset + Math.floor(width * (count / (size - 1)));
    }
  
    // Update range if any provided
    if (range) {
      min = range[0];
      max = range[1];
    }
  
    const scaleY = height / (max - min);
  
    function getY(idx) {
      let value = values[idx];
      value = value > min ? (value < max ? value : max) : min;
      return yOffset + height - Math.floor((value - min) * scaleY);
    }
  
    // Draw line
    ctx.beginPath();
    ctx.lineWidth = 1;
    ctx.strokeStyle = field.color;
    ctx.moveTo(xValues[0], getY(0));
    for (let idx = 1; idx < size; idx++) {
      if (Number.isNaN(values[idx])) {
        if (idx + 1 < size && !Number.isNaN(values[idx + 1])) {
          ctx.moveTo(xValues[idx + 1], getY(idx + 1));
        }
      } else {
        ctx.lineTo(xValues[idx], getY(idx));
      }
    }
    ctx.stroke();
  }
docs: ---------------------------------------------------------------------------- Helpers ----------------------------------------------------------------------------