diff --git a/rowers/.#dataroutines.py b/rowers/.#dataroutines.py new file mode 120000 index 00000000..f9fb1e7f --- /dev/null +++ b/rowers/.#dataroutines.py @@ -0,0 +1 @@ +sander@rowsandall-2.231246:1710428505 \ No newline at end of file diff --git a/rowers/dataroutines.py b/rowers/dataroutines.py index ff0a8440..d444843c 100644 --- a/rowers/dataroutines.py +++ b/rowers/dataroutines.py @@ -1273,7 +1273,7 @@ def getsmallrowdata_db(columns, ids=[], doclean=True, workstrokesonly=True, comp data.append(df) except (OSError, ArrowInvalid, IndexError): pass - + df['workoutid'] = id try: df = pd.concat(data, axis=0) except ValueError: # pragma: no cover @@ -1314,6 +1314,7 @@ def getsmallrowdata_db(columns, ids=[], doclean=True, workstrokesonly=True, comp workstrokesonly=workstrokesonly) data.dropna(axis=1, how='all', inplace=True) data.dropna(axis=0, how='any', inplace=True) + print(data) return data except TypeError: pass diff --git a/rowers/interactiveplots.py b/rowers/interactiveplots.py index 2fb4810e..c070913b 100644 --- a/rowers/interactiveplots.py +++ b/rowers/interactiveplots.py @@ -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 ['', '

No non-zero data in selection

', '', '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] diff --git a/rowers/tests/testdata/testdata.tcx.gz b/rowers/tests/testdata/testdata.tcx.gz index 23e0b601..078ead98 100644 Binary files a/rowers/tests/testdata/testdata.tcx.gz and b/rowers/tests/testdata/testdata.tcx.gz differ