Private
Public Access
1
0

trend line

This commit is contained in:
Sander Roosendaal
2022-09-13 19:58:01 +02:00
parent b893653781
commit 6f723cc66a
6 changed files with 63 additions and 6 deletions

View File

@@ -4658,7 +4658,8 @@ def interactive_cum_flex_chart2(theworkouts, promember=0,
xparam='spm',
yparam1='power',
yparam2='spm',
workstrokesonly=False):
workstrokesonly=False,
trendline=False):
# datadf = dataprep.smalldataprep(theworkouts,xparam,yparam1,yparam2)
ids = [int(w.id) for w in theworkouts]
@@ -4747,6 +4748,15 @@ def interactive_cum_flex_chart2(theworkouts, promember=0,
else: # pragma: no cover
datadf['yname2'] = axlabels[yparam1]
def func(x, a, b):
return a*x+b
x1 = datadf['x1']
y1 = datadf['y1']
popt, pcov = optimize.curve_fit(func, x1, y1)
ytrend = func(x1, popt[0], popt[1])
datadf['ytrend'] = ytrend
source = ColumnDataSource(
datadf
)
@@ -4848,6 +4858,10 @@ def interactive_cum_flex_chart2(theworkouts, promember=0,
minutes=["%M"]
)
# trendline
if trendline:
plot.line('x1', 'ytrend', source=source2, legend_label=yparamname1+' (trend)')
if yparam2 != 'None':
yrange2 = Range1d(start=yaxminima[yparam2], end=yaxmaxima[yparam2])
plot.extra_y_ranges["yax2"] = yrange2
@@ -5392,6 +5406,7 @@ def interactive_flex_chart2(id, r, promember=0,
yparam2='hr',
plottype='line',
workstrokesonly=False,
trendline=False,
mode='rower'):
watermarkurl = "/static/img/logo7.png"
@@ -5557,6 +5572,15 @@ def interactive_flex_chart2(id, r, promember=0,
else: # pragma: no cover
rowdata['yname2'] = rowdata['yname1']
def func(x, a, b):
return a*x+b
x1 = rowdata['x1']
y1 = rowdata['y1']
popt, pcov = optimize.curve_fit(func, x1, y1)
ytrend = func(x1, popt[0], popt[1])
rowdata['ytrend'] = ytrend
# prepare data
source = ColumnDataSource(
rowdata
@@ -5672,6 +5696,10 @@ def interactive_flex_chart2(id, r, promember=0,
plot.line(xvals, yconstantpower, color="green",
legend_label="Constant Power")
# trendline
if trendline:
plot.line('x1', 'ytrend', source=source2, legend_label=yaxlabel+' (trend)')
if plottype == 'line':
plot.line('x1', 'y1', source=source2, legend_label=yaxlabel)
elif plottype == 'scatter': # pragma: no cover