Request for KJ display and cumulative workout data in Fitness section

Hello,

Would it be possible to display the kilojoules (kJ) expended during swimming workouts by multiplying the kilocalories (kcal) burned by 4.184, which is known as the “thermochemical calorie” according to the ISO 31-4 standard?

If so, how can I accumulate this value in my “Work” graph on my fitness page along with those from my running and cycling activities to get a weekly workload?

Thank you

You can do this using a custom activity field. These can modify “normal” fields. Try create custom activity field with script like this:

{
  if (activity.type === 'Swim') {
    activity.icu_joules = Math.floor(activity.calories * 4.184)
  }
}

Thanks @david

I had thought about coding the same thing.

function calculateEnergy(activity) {
  if (activity.calories <= 0) {
    // console.log("calories", activity.calories);
    return 0;
  }

  switch (activity.type) {
    case "Swim":
      return Math.floor(activity.calories * 4.184);
    case "Run":
      return Math.floor(activity.icu_joules / 1000);
	case "VirtualRide":
	  return Math.floor(activity.icu_joules / 1000);
    case "Ride":
      return Math.floor(activity.icu_joules / 1000);
    default:
      return 0;
  }
}

energy = calculateEnergy(activity)

However, this is not the formula you use for calculating activities of type ‘Run’ or ‘Ride’ (activity.icu_joules)

image

The conversion factor used is: 1 kcal = 4.184 kJ
Therefore, 856 kcal × 4.184 = 3582.144 kJ, rounded to 3582 kJ

There is something I don’t understand

You don’t have 100% efficiency. The efficiency is somewhere in 22% to 25%. You still have to include the efficiency.

3 Likes

Indeed, the human body’s efficiency in converting chemical energy into mechanical work is not 100%. I hadn’t considered this aspect.

I need to correct my function because swimming would have the lowest energy efficiency of the three disciplines. Studies show that swimming efficiency is generally less than 10%, often ranging between 6% and 8%.

Some experts (sports scientists, physiologists) are saying that it’s closer to 20%, even among some professionals. The really good pros might be closer to 25%, but not all the time.

Thanks David! But could we still have it as an option in the settings page please, like how we pick kms instead of miles etc? I don’t know about other countries, but in Australia we use kjoules for everything (eg, all the information on food packaging is in kJ). It would be so much easier and intuitive if we didn’t need to write code - I don’t know how to write the javascript and am not sure how to adjust it for my situation (eg, the field I’ve adapted from your above doesn’t update unless I go into the script window and select the ‘play’ arrow).

for existing activities, it need to be reprocesed via action-reprocess. It will stick and auto for new activities as they come in.