diff --git a/rowers/interactiveplots.py b/rowers/interactiveplots.py index 9732440c..2cc207c0 100644 --- a/rowers/interactiveplots.py +++ b/rowers/interactiveplots.py @@ -2499,25 +2499,64 @@ def interactive_flex_chart2(id=0,promember=0, return [script,div,js_resources,css_resources,workstrokesonly] -def thumbnail_flex_chart(id=0,promember=0, - xparam='time', - yparam1='pace', - yparam2='hr', - plottype='line', - workstrokesonly=False): +def thumbnails_set(r,id,favorites): + charts = [] + columns = [f.xparam for f in favorites] + columns += [f.yparam1 for f in favorites] + columns += [f.yparam2 for f in favorites] - #rowdata,row = dataprep.getrowdata_db(id=id) - columns = [xparam,yparam1,yparam2,'time'] - - rowdata = dataprep.getsmallrowdata_db(columns,ids=[id],doclean=True, - workstrokesonly=workstrokesonly) + columns += ['time'] + rowdata = dataprep.getsmallrowdata_db(columns,ids=[id],doclean=True) + rowdata.dropna(axis=1,how='all',inplace=True) if rowdata.empty: - rowdata = dataprep.getsmallrowdata_db(columns,ids=[id],doclean=True, - workstrokesonly=False) - workstrokesonly=False + return [ + {'script':"", + 'div':"", + 'notes':"" + }] + else: + try: + rowdata.sort_values(by='time',ascending=True,inplace=True) + except KeyError: + pass + + l = len(rowdata) + maxlength = 50 + if l > maxlength: + bins = np.linspace(rowdata['time'].min(),rowdata['time'].max(),maxlength) + groups = rowdata.groupby(np.digitize(rowdata['time'],bins)) + rowdata = groups.mean() + for f in favorites: + workstrokesonly = not f.reststrokes + script,div = thumbnail_flex_chart( + rowdata, + id=id, + xparam=f.xparam, + yparam1=f.yparam1, + yparam2=f.yparam2, + plottype=f.plottype, + ) + + + charts.append({ + 'script':script, + 'div':div, + 'notes':f.notes}) + + return charts + + +def thumbnail_flex_chart(rowdata,id=0,promember=0, + xparam='time', + yparam1='pace', + yparam2='hr', + plottype='line', + workstrokesonly=False): + + try: tests = rowdata[yparam2] except KeyError: @@ -2528,25 +2567,7 @@ def thumbnail_flex_chart(id=0,promember=0, except KeyError: yparam1 = 'None' - rowdata.dropna(axis=1,how='all',inplace=True) - if rowdata.empty: - return "","No valid data" - else: - try: - rowdata.sort_values(by='time',ascending=True,inplace=True) - except KeyError: - pass - - workoutstateswork = [1,4,5,8,9,6,7] - workoutstatesrest = [3] - workoutstatetransition = [0,2,10,11,12,13] - - if workstrokesonly: - try: - rowdata = rowdata[~rowdata['workoutstate'].isin(workoutstatesrest)] - except KeyError: - pass try: tseconds = rowdata.ix[:,'time'] @@ -2620,11 +2641,6 @@ def thumbnail_flex_chart(id=0,promember=0, plot.yaxis.axis_label_text_font_size = "7pt" plot.xaxis.major_label_text_font_size = "7pt" plot.yaxis.major_label_text_font_size = "7pt" - # add watermark - plot.extra_y_ranges = {"watermark": watermarkrange} - plot.extra_x_ranges = {"watermark": watermarkrange} - - if plottype=='line': plot.line('x1','y1',source=source) diff --git a/rowers/templates/flexthumbnails.html b/rowers/templates/flexthumbnails.html new file mode 100644 index 00000000..d6a5016a --- /dev/null +++ b/rowers/templates/flexthumbnails.html @@ -0,0 +1,11 @@ + {% for chart in charts %} +
+ Edit Workout +
++ Advanced +
++ Edit Intervals +
++ Add Time Plot +
++ Add Pie Chart +
++ Workout Stats +
++
+ {{ workout.summary }}
+
+
diff --git a/rowers/templates/workflow.html b/rowers/templates/workflow.html
index 2a454179..a4fe822f 100644
--- a/rowers/templates/workflow.html
+++ b/rowers/templates/workflow.html
@@ -25,17 +25,29 @@
{% endblock %}
{% block content %}
-+ {% endblock %}