Pacing insight (as a field) and chart with calculated value

I kind of have two questions in one post:

  • How would I be able to gain insight in the negative/positive pacing on a lap level with a field? (kind of similar to decoupling: (average speed 1st half)/(average speed 2nd half) )

  • Would it be possible to create a chart with a custom/calculated value/data stream. Specifically looking to visualize distance per stroke over time, but would be applicable in more scenarios I figure.

Thanks in advance for the help on either of them.

For the first one you could probably create a computed activity field with a script to do that. This would also work as a custom interval field. You can get the velocity_smooth stream and work with that:

{
  let velocity = streams.get("velocity_smooth").data
  
  function avgVelocity(start, end) {
    let tot = 0
    let c = 0
    for (let i = start; i < end; i++) {
      let v = velocity[i]
      if (v) {
        tot += v
        ++c
      }
    }
    return c ? tot / c : null
  }
  
  let mid = Math.floor((interval.start_index + interval.end_index) / 2)
  let first = avgVelocity(interval.start_index, mid)
  let second = avgVelocity(mid, interval.end_index)
  second ? first/second : null
}

Not yet but that is high up on the todo list. Also creating such streams from messages in the fit file.

1 Like

Thank you for the help!

I’ll try the script on my activities.

I can kind of figure out what’s happening in the example you provided, but is there any documentation or recourse for my future questions?

Not too much unfortunately. That link above and these:

A good resource is to search for other people’s stuff and look at their scripts.