Custom activity streams with Javascript

Sure you can get those from the activity:

  let mhr = activity.athlete_max_hr
  let rhr = activity.icu_resting_hr

For an interval field you can calculate the average like this:

{
  let mhr = activity.athlete_max_hr
  let rhr = activity.icu_resting_hr
  let hr = icu.streams.fixed_heartrate
  let power = icu.streams.fixed_watts
  let tot = 0, c = 0
  for (let i = interval.start_index; i < interval.end_index; i++) { 
    let v = power[i] / (((hr[i] - rhr) / (mhr - rhr))*100) 
    if (v) {
      tot += v
      ++c
    }
  }
  c ? tot/c : null
}
2 Likes