Average value of a pen on an easy chart

Hi,

Unfortunately, I think your best bet currently is to do what you thought, and take the average of the dataset. In theory what you want to do with the queryTagHistory should work, using start=x, end=y, mode=avg, and returnSize=1. However, that call currently returns two values, one for the bounding value, and then the average for the rest of the time frame, leaving it not quite correct.

We are currently working on improving all of this in various ways. First, to make it much easier to run these types of queries through the queryTagHistory function, with more aggregate functions (numeric average vs. time weighted is one example), fixing how they work for 1 result, and new ways to specify time range. For example, to get the average over the last 8 hours, you would be able to simply do something like queryTagHistory(paths=[‘tag’], rangeHours=-8, aggregationMode=‘Average’, returnSize=1). This functionality should be available by the middle of May.

One other thing that I would suggest for right now, though: create your own version of the query function as a script module that queries for return size of 10 or so, and then does the averaging. That way you can then use it in multiple places.

Regards,