I created this chart for visualize every single power data at each cadence value for entire activity.
Is possible to have a help fo visualize same value but for each interval…I tried without success…
This is the chart…
You can do that. Here is some code that calculates average power for each work interval from the fixed_watts stream. It’s a bit contrived because average_watts is available as a field on the interval but does show how to work with interval data. The start_index (inclusive) and end_index (exclusive) are how you can get stream data for an interval.
Also you should use “fixed_watts” instead of “watts”. This has spikes clipped, dropouts fixed and so on.
{
let activity = icu.activity
let watts = icu.streams.fixed_watts
let x = []
let y = []
let intervals = activity.icu_intervals || []
for (let i = 0, c = 0; i < intervals.length; i++) {
let iv = intervals[i]
if (iv.type !== 'WORK') continue
let tot = 0, num = 0
for (let j = iv.start_index; j < iv.end_index; j++) {
let v = watts[j]
if (v !== null) {
tot += v
++num
}
}
let avgWatts = num > 0 ? tot/num : 0
++c
x.push(iv.label || c)
y.push(avgWatts /*iv.average_watts*/)
}
let data = [
{
x: x,
y: y,
type: 'bar',
marker: {
color: '#63c',
opacity: 0.7
}
}
]
let layout = {
title: {
text: "Average power for work intervals"
},
margin: {
l: 30,
r: 20,
t: 20,
b: 30
}
}
chart = { data, layout }
}
I thought that is what you were looking for? If you want the underlying data for each interval you need to use the start_index and end_index fields and work with the streams.
@Manuel_Oberti
Just shared the chart. I have also added colored points depending on power zone following color code in intervals.
As mentioned by chat, in case of high amount of intervals in the activity, readability will be affected, but I think this chart covers what you were looking for.
Look for intervalsPWRCAD in the custom charts list
I thought you wanted all intervals in sequence
Better to enable or disable intervals visibility in a single plot as you did to improve readability
Good work!