Access to the surrounding values

Trends comes with a handy function getAround. For each point, it returns an array with the surrounding values. This is useful to measure derivatives or max/min/averages... with standard Javascript

getAround(name, countBefore, countAfter)

  • name: the name of the parameter as string

  • countBefore: the count of samples to get before the current point

  • countAfter: the count of samples to get after the current point

// smothes the trend by averaging the last 4 samples. Current value is 9.1
// getAround returns ["2.6", "11.4", "2.6", "9.1"]
if(DELTA_PACK_P>0){
	return getAround("DELTA_PACK_P", 3, 0).mean();
}

Last updated

Was this helpful?