Time in Torque Zones

Hello everybody,
I would like to monitor torque and I think it would be helpful to define torque zones in Nm and be able to see time in each torque zone in a similar way as time in power zones.
Can somebody help me create a chart as I don’t programming and code stuff.

Thank you in advance.

1 Like

try this thread?

maybe can use that as a springboard

I added a “Time in torque zones” chart. You can search for that.

Here is the code. Anyone know how to get rid of the x axis or at least the tick labels?

{
  // max Nm for each zone
  let zones = [20, 40, 60, 999]
  let tiz = []
  for (let z of zones) tiz.push(0)
  let torque = icu.streams.torque
  let time = icu.streams.time
  for (let i = 0; i < torque.length; i++) {
    let secs = i > 0 ? time[i] - time[i - 1] : 1
    if (secs >= 30) continue
    let nm = torque[i]
    if (nm <= 0) continue
    for (let j = 0; j < zones.length; j++) {
      if (nm <= zones[j]) {
        tiz[j] += secs
        break
      }
    }
  }

  let y = []
  y.push("0-" + zones[0] + " Nm")
  for (let i = 1; i < zones.length - 1; i++) y.push(zones[i -1 ] + "-" + zones[i] + " Nm")
  y.push(zones[zones.length - 2] + "+ Nm")

  const ZoneColours = ["#009e80", "#009e00", "#ffcb0e", "#ff7f0e", "#dd0447", "#6633cc", "#504861" ]

  function formatTime(secs) {
    let s = secs % 60
    let m = Math.floor(secs / 60)
    let h = Math.floor(m / 60)
    m %= 60
    return h + ":" + (m < 10 ? "0" : "") + m + ":" + (s < 10 ? "0" : "") + s
  }

  let data = [{
    type: 'bar',
    x: tiz,
    y: y,
    text: tiz.map(formatTime),
    textposition: 'auto',
    hoverinfo: 'none',
    marker:{
      color: ZoneColours
    },
    orientation: 'h'
  }]

  let layout = {
    title: {
      text: "Time in torque zones",
      font: { color: 'black', size: 20 }
    }
  }

  chart = { data, layout }
}

That’s fantastic! Thank you very much!

Hi David, is there a way to add “Time in Torque Zones” to the Fitness Chart to see each day’s summary? Right now I can see a summary of time spent in different HR and Power zones but there is no such metrics for Torque.

I searched for this and found this post Time in Torque Zones - #3 by david? However, I have searched everywhere (as in custom charts → charts → search) for the Time in torque zones” chart, and have not found it.

That one is per session, but the idea is to have stacked bars of time in torque zones on “Fitness” page to compare days, weeks or months between each other.