I am trying to plot a trendline for an existing Pi tag based on linear regression, inside Pi Vision. This is similar to we do in excel, with trendline on a scatter plot.

I was able to use the LinRegr function to get the slope, intercept and R2 as part of 3-point array output.

Now I am tried to use these LinRegr output arguments to reconstruct a trendline and pass it on to a Pi AF attribute and plot in Vision. I get stuck here.

I am using this kind of formula :

Trendline = LinRegr[1] * Float('*' - 'starttime') + LinRegr[2].

This equation does evaluate to a number in the analysis window. However when I try to plot it in PSE it gets stuck forever.