Private
Public Access
1
0

first attempt compare

This commit is contained in:
2024-03-17 09:56:10 +01:00
parent 453cc79430
commit 0da6237e57
4 changed files with 45 additions and 25 deletions

View File

@@ -399,7 +399,11 @@ def interactive_boxchart(datadf, fieldname, extratitle='',
if 'date' not in columns: # pragma: no cover
return '', 'Not enough data'
datadf.date = datadf.date.apply(lambda x:x.strftime("%Y-%m-%d"))
try:
datadf.date = datadf.date.apply(lambda x:x.strftime("%Y-%m-%d"))
except AttributeError:
datadf.date = "2000-01-01"
datadf['value'] = datadf[fieldname]
data_dict = datadf.to_dict("records")
boxplot_data = {
@@ -3973,9 +3977,8 @@ def interactive_cum_flex_chart2(theworkouts, promember=0,
extratitle='',
trendline=False):
# datadf = dataprep.smalldataprep(theworkouts,xparam,yparam1,yparam2)
ids = [int(w.id) for w in theworkouts]
#columns = [xparam, yparam1, yparam2, 'spm', 'driveenergy', 'distance']
columns = [name for name, d in metrics.rowingmetrics]
columns_basic = [name for name, d in metrics.rowingmetrics if d['group'] == 'basic']
columns = columns + ['spm', 'driveenergy', 'distance']
@@ -4048,20 +4051,6 @@ def interactive_cum_flex_chart2(theworkouts, promember=0,
else: # pragma: no cover
datadf['y2'] = datadf['y1']
# average values
x1mean = datadf['x1'].mean()
y1mean = datadf['y1'].mean()
y2mean = datadf['y2'].mean()
x_axis_type = 'linear'
y_axis_type = 'linear'
if xparam == 'time':
x_axis_type = 'datetime'
if yparam1 == 'pace': # pragma: no cover
y_axis_type = 'datetime'
y1mean = datadf.loc[:, 'pace'].mean()
datadf['xname'] = axlabels[xparam]
datadf['yname1'] = axlabels[yparam1]
@@ -5285,19 +5274,28 @@ def interactive_multiple_compare_chart(ids, xparam, yparam, plottype='line',
message = ''
errormessage = ''
columns = [xparam, yparam,
'ftime', 'distance', 'fpace',
'power', 'hr', 'spm',
'time', 'pace', 'workoutstate',
'workoutid']
columns = [name for name, d in metrics.rowingmetrics]
columns_basic = [name for name, d in metrics.rowingmetrics if d['group'] == 'basic']
columns = columns + ['spm', 'driveenergy', 'distance']
columns_basic = columns_basic + ['spm', 'driveenergy', 'distance']
compute = False
doclean = False
if workstrokesonly:
compute = True
doclean = True
datadf = dataprep.getsmallrowdata_db(columns, ids=ids, doclean=doclean, compute=compute,
workstrokesonly=workstrokesonly)
datadf = pd.DataFrame()
if promember:
datadf = dataprep.getsmallrowdata_db(columns, ids=ids, doclean=doclean,
compute=compute,
workstrokesonly=workstrokesonly)
else:
datadf = dataprep.getsmallrowdata_db(columns, ids=ids, doclean=doclean,
compute=compute,
workstrokesonly=workstrokesonly)
datadf.dropna(axis=1, how='all', inplace=True)
datadf.dropna(axis=0, how='any', inplace=True)
@@ -5315,6 +5313,26 @@ def interactive_multiple_compare_chart(ids, xparam, yparam, plottype='line',
if datadf.empty: # pragma: no cover
return ['', '<p>No non-zero data in selection</p>', '', 'No non-zero data in selection']
data_dict = datadf.to_dict("records")
metrics_list = [{'name': name, 'rowingmetrics':d } for name, d in metrics.rowingmetrics]
workoutsdict = [{'id': id, 'label': labeldict[id]} for id in ids]
chart_data = {
'title': '',
'x': xparam,
'y': yparam,
'data': data_dict,
'metrics': metrics_list,
'plottype': plottype,
'workouts': workoutsdict,
}
script, div = get_chart("/compare", chart_data)
return script, div, message, errormessage
if xparam != 'distance' and xparam != 'time' and xparam != 'cumdist': # pragma: no cover
xaxmax = yaxmaxima[xparam]
xaxmin = yaxminima[xparam]