Is there any way to access the custom (or standard) interval fields in the custom charts on the fitness page? I have some specific use cases for tracking training blocks which I would love it be able to do but requires access to the interval fields.
Not directly. But you can create a custom activity field that stores data computed from the interval fields (standard and custom) and use that on the /fitness page. Not sure if that will work for your use-case.
Yes, that sounds like it would work…now just to figure out how to do that
Essentially, I want to be able to capture this information from work intervals, into activity fields so that I can chart them on the /fitness page…
Is that possible?
Yes sort of. You would need to add a custom activity field for each and compute it from the intervals yourself. This will work best if there is only one activity for the sport on each day. I suggest testing with just one field before doing all the work.
That is great thanks @david - I need to do some digging on how to create the script to do as such then…starting from zero
If anyone has any examples of creating an activity field by computing it from an interval they could share to get me start that would be fantastic.
Here’s one that calculates Running Efficiency per Interval
if ((activity.type == “Run” || activity.type == “VirtualRun”) && !activity.icu_ignore_hr)
{
gaStr = streams.get(“ga_velocity”).data
xgap = 0
gaSmooth = 0
smoothBy = 30 //seconds
count = interval.end_index - interval.start_index
for (let i=0; i<count; i++)
{
gaSmooth = gaSmooth + gaStr[interval.start_index + i]
if(i%smoothBy == 0 || i+1 == count)
{
xgap = xgap + ((gaSmooth/smoothBy ) ** 4)
gaSmooth = 0
}
}
//calculates normalized average
xgap = (xgap / Math.ceil(count/smoothBy))**(1/4)
eff = (xgap * 60) / (activity.average_heartrate)
eff = +eff.toFixed(2)
}
Thanks @MedTechCD…I’m well out my depth
I am in the first instance just trying to to calculate the Elapsed Time of the WORK intervals into a activity field - if I can figure that out, I should be able to do it for the other fields (Avg Power, Avg HR%, etc)
Interval length in sec is ‘interval.end_index - interval.start_index + 1’
Example from my Interval box plots:
// get list of intervals
let intervals = activity.icu_intervals ||
// check each interval. If it is a work interval, stock its nr and label in separate arrays.
for (let i = 0, c = 0; i < intervals.length; i++) {
let iv = intervals[i]
if (iv.type !== ‘WORK’) continue
wi_nr.push(i)
++c
wi_lbl.push(iv.label ? c + ‘-’ + iv.label : c)
multi_label.push(‘#’ + (iv.label ? iv.label : ‘’))
}
Yep sorry @MedTechCD I am lost…I will go do some reading as I don’t have anywhere enough understanding to reverse engineer this. Thanks for help though
I understand the logic of what needs to be done but I don’t know enough ref JS to be able to write it. It’s highly frustrating…I need to find some time to learn…
My logic says…
- Look for all intervals in an activity
- If the interval is a WORK interval then
- Calculate the total interval length from the start and end time
- Convert the calculation to minutes
- Print the output to the custom activity field
Here is a script to calculate the average duration of the work intervals:
{
let tot = 0, n = 0
for (let iv of activity.icu_intervals) {
if (iv.type !== 'WORK') continue
//console.log("iv.elapsed_time", iv.elapsed_time)
tot += iv.elapsed_time
++n
}
n > 0 ? tot/n : null
}
You can uncomment the console.log to see each value.
You can use the “Convert” option on the custom activity field to display the seconds value as time.
Here are all the fields available on each interval: Server side data model for scripts
Thank you @david - let me see what I can figure out from here (total work interval time and averages for maxhr%, EF, Power, etc)
Pleased to say I am getting somewhere @david!
Looking at the available server side data model fields, is it possible for you add ‘AvgHR%’ and’ Efficiency Factor’ at interval level please?
Those are computed on the fly from the existing fields to save space. Something like this:
let ef = iv.weighted_average_watts / iv.average_heartrate
let avg_hr_p = iv.average_heartrate * 100 / activity.athlete_max_hr
Again, thank you! Got it all working now!
Hi,
Would like to have the code or script to add time/500m plot on the charts. This is a popular metric for rowing activities. Thanks
You can configure pace units for rowing in /settings:
Choose “per 500m” and capture a threshold pace. Then pace analysis will be done for rowing and pace will be displayed in “time per 500m”. I don’t think you need custom fields for this.
This works great, thank you
Hey david how are yoou?
Its possible define “Power Curve”; for each activity? I realize i can define Power curver 3 points , but not for each specific activity - The graph plot the same for all activities
Good thanks. I don’t quite understand what you are asking for?