# Custom interval fields

**URL:** <https://forum.intervals.icu/t/custom-interval-fields/25942>\
**Category:** Uncategorized\
**Created:** [27 December 2022 09:54 UTC](https://forum.intervals.icu/t/custom-interval-fields/25942 "2022-12-27T09:54:04Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![Olly\_Thomas](https://forum.intervals.icu/user_avatar/forum.intervals.icu/olly_thomas/32/28972_2.png) [@Olly\_Thomas](https://forum.intervals.icu/u/Olly_Thomas)\
**Post date:** [22 March 2024 10:44 UTC](https://forum.intervals.icu/t/custom-interval-fields/25942/41 "2024-03-22T10:44:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![david](https://forum.intervals.icu/user_avatar/forum.intervals.icu/david/32/30189_2.png) [@david](https://forum.intervals.icu/u/david)\
**Post date:** [22 March 2024 11:04 UTC](https://forum.intervals.icu/t/custom-interval-fields/25942/42 "2024-03-22T11:04:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Olly\_Thomas](https://forum.intervals.icu/user_avatar/forum.intervals.icu/olly_thomas/32/28972_2.png) [@Olly\_Thomas](https://forum.intervals.icu/u/Olly_Thomas)\
**Post date:** [22 March 2024 11:09 UTC](https://forum.intervals.icu/t/custom-interval-fields/25942/43 "2024-03-22T11:09:22Z")

</div>

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…

 ![image](https://forum.intervals.icu/uploads/default/original/3X/e/b/eb279ef4fc65ac6b9b60417899fad17fab04e21b.png)

Is that possible?

---

<div class="post-metadata">

**Author:** ![david](https://forum.intervals.icu/user_avatar/forum.intervals.icu/david/32/30189_2.png) [@david](https://forum.intervals.icu/u/david)\
**Post date:** [22 March 2024 11:40 UTC](https://forum.intervals.icu/t/custom-interval-fields/25942/44 "2024-03-22T11:40:54Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Olly\_Thomas](https://forum.intervals.icu/user_avatar/forum.intervals.icu/olly_thomas/32/28972_2.png) [@Olly\_Thomas](https://forum.intervals.icu/u/Olly_Thomas)\
**Post date:** [22 March 2024 11:45 UTC](https://forum.intervals.icu/t/custom-interval-fields/25942/45 "2024-03-22T11:45:56Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![MedTechCD](https://forum.intervals.icu/user_avatar/forum.intervals.icu/medtechcd/32/40383_2.png) [@MedTechCD](https://forum.intervals.icu/u/MedTechCD)\
**Post date:** [22 March 2024 12:03 UTC](https://forum.intervals.icu/t/custom-interval-fields/25942/46 "2024-03-22T12:03:54Z")

</div>

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)  
> }

---

<div class="post-metadata">

**Author:** ![Olly\_Thomas](https://forum.intervals.icu/user_avatar/forum.intervals.icu/olly_thomas/32/28972_2.png) [@Olly\_Thomas](https://forum.intervals.icu/u/Olly_Thomas)\
**Post date:** [22 March 2024 13:40 UTC](https://forum.intervals.icu/t/custom-interval-fields/25942/47 "2024-03-22T13:40:56Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![MedTechCD](https://forum.intervals.icu/user_avatar/forum.intervals.icu/medtechcd/32/40383_2.png) [@MedTechCD](https://forum.intervals.icu/u/MedTechCD)\
**Post date:** [22 March 2024 13:54 UTC](https://forum.intervals.icu/t/custom-interval-fields/25942/48 "2024-03-22T13:54:41Z")

</div>

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 : ‘’))  
> }

---

<div class="post-metadata">

**Author:** ![Olly\_Thomas](https://forum.intervals.icu/user_avatar/forum.intervals.icu/olly_thomas/32/28972_2.png) [@Olly\_Thomas](https://forum.intervals.icu/u/Olly_Thomas)\
**Post date:** [22 March 2024 14:00 UTC](https://forum.intervals.icu/t/custom-interval-fields/25942/49 "2024-03-22T14:00:27Z")

</div>

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 👍🏼

---

<div class="post-metadata">

**Author:** ![Olly\_Thomas](https://forum.intervals.icu/user_avatar/forum.intervals.icu/olly_thomas/32/28972_2.png) [@Olly\_Thomas](https://forum.intervals.icu/u/Olly_Thomas)\
**Post date:** [22 March 2024 17:51 UTC](https://forum.intervals.icu/t/custom-interval-fields/25942/50 "2024-03-22T17:51:58Z")

</div>

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…

1. Look for all intervals in an activity
2. If the interval is a WORK interval then
3. Calculate the total interval length from the start and end time
4. Convert the calculation to minutes
5. Print the output to the custom activity field

---

<div class="post-metadata">

**Author:** ![david](https://forum.intervals.icu/user_avatar/forum.intervals.icu/david/32/30189_2.png) [@david](https://forum.intervals.icu/u/david)\
**Post date:** [23 March 2024 04:53 UTC](https://forum.intervals.icu/t/custom-interval-fields/25942/51 "2024-03-23T04:53:42Z")

</div>

Here is a script to calculate the average duration of the work intervals:

```auto
{
  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](https://forum.intervals.icu/t/server-side-data-model-for-scripts/25781#Interval)

---

<div class="post-metadata">

**Author:** ![Olly\_Thomas](https://forum.intervals.icu/user_avatar/forum.intervals.icu/olly_thomas/32/28972_2.png) [@Olly\_Thomas](https://forum.intervals.icu/u/Olly_Thomas)\
**Post date:** [24 March 2024 06:33 UTC](https://forum.intervals.icu/t/custom-interval-fields/25942/52 "2024-03-24T06:33:46Z")

</div>

Thank you 🙏🏼 @david - let me see what I can figure out from here (total work interval time and averages for maxhr%, EF, Power, etc)

---

<div class="post-metadata">

**Author:** ![Olly\_Thomas](https://forum.intervals.icu/user_avatar/forum.intervals.icu/olly_thomas/32/28972_2.png) [@Olly\_Thomas](https://forum.intervals.icu/u/Olly_Thomas)\
**Post date:** [25 March 2024 13:52 UTC](https://forum.intervals.icu/t/custom-interval-fields/25942/53 "2024-03-25T13:52:58Z")

</div>

Pleased to say I am getting somewhere @david!

![image](https://forum.intervals.icu/uploads/default/original/3X/c/d/cd58463c83623ecc32edd61a59237e1028f2cf3f.png)

Looking at the available server side data model fields, is it possible for you add ‘AvgHR%’ and’ Efficiency Factor’ at interval level please?

---

<div class="post-metadata">

**Author:** ![david](https://forum.intervals.icu/user_avatar/forum.intervals.icu/david/32/30189_2.png) [@david](https://forum.intervals.icu/u/david)\
**Post date:** [25 March 2024 15:59 UTC](https://forum.intervals.icu/t/custom-interval-fields/25942/54 "2024-03-25T15:59:27Z")

</div>

Those are computed on the fly from the existing fields to save space. Something like this:

```auto
let ef = iv.weighted_average_watts / iv.average_heartrate
let avg_hr_p = iv.average_heartrate * 100 / activity.athlete_max_hr

```

---

<div class="post-metadata">

**Author:** ![Olly\_Thomas](https://forum.intervals.icu/user_avatar/forum.intervals.icu/olly_thomas/32/28972_2.png) [@Olly\_Thomas](https://forum.intervals.icu/u/Olly_Thomas)\
**Post date:** [25 March 2024 19:25 UTC](https://forum.intervals.icu/t/custom-interval-fields/25942/55 "2024-03-25T19:25:08Z")

</div>

Again, thank you! Got it all working now! 👌🏼

---

<div class="post-metadata">

**Author:** ![Marty\_Boyd](https://forum.intervals.icu/user_avatar/forum.intervals.icu/marty_boyd/32/35887_2.png) [@Marty\_Boyd](https://forum.intervals.icu/u/Marty_Boyd)\
**Post date:** [9 April 2024 23:31 UTC](https://forum.intervals.icu/t/custom-interval-fields/25942/56 "2024-04-09T23:31:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![david](https://forum.intervals.icu/user_avatar/forum.intervals.icu/david/32/30189_2.png) [@david](https://forum.intervals.icu/u/david)\
**Post date:** [10 April 2024 03:53 UTC](https://forum.intervals.icu/t/custom-interval-fields/25942/57 "2024-04-10T03:53:48Z")

</div>

You can configure pace units for rowing in /settings:

 ![Screenshot 2024-04-10 at 05.51.40](https://forum.intervals.icu/uploads/default/original/3X/4/7/475504751319ed738dd43952a4fec0f1a678765e.png)

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.

---

<div class="post-metadata">

**Author:** ![Marty\_Boyd](https://forum.intervals.icu/user_avatar/forum.intervals.icu/marty_boyd/32/35887_2.png) [@Marty\_Boyd](https://forum.intervals.icu/u/Marty_Boyd)\
**Post date:** [10 April 2024 09:11 UTC](https://forum.intervals.icu/t/custom-interval-fields/25942/58 "2024-04-10T09:11:51Z")

</div>

This works great, thank you

---

<div class="post-metadata">

**Author:** ![R\_S1](https://forum.intervals.icu/user_avatar/forum.intervals.icu/r_s1/32/27267_2.png) [@R\_S1](https://forum.intervals.icu/u/R_S1)\
**Post date:** [27 April 2024 22:48 UTC](https://forum.intervals.icu/t/custom-interval-fields/25942/59 "2024-04-27T22:48:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![david](https://forum.intervals.icu/user_avatar/forum.intervals.icu/david/32/30189_2.png) [@david](https://forum.intervals.icu/u/david)\
**Post date:** [29 April 2024 18:04 UTC](https://forum.intervals.icu/t/custom-interval-fields/25942/60 "2024-04-29T18:04:33Z")

</div>

Good thanks. I don’t quite understand what you are asking for?

[Previous page](https://forum.intervals.icu/t/custom-interval-fields/25942.md?page=2)

[Next page](https://forum.intervals.icu/t/custom-interval-fields/25942.md?page=4)
