Private
Public Access
1
0

adding extra parameters to X axis flex chart

This commit is contained in:
Sander Roosendaal
2018-03-14 13:39:52 +01:00
parent f890ffa019
commit b502244733
6 changed files with 62 additions and 27 deletions

View File

@@ -1686,9 +1686,13 @@ def getsmallrowdata_db(columns, ids=[], doclean=True, workstrokesonly=True):
cdata = row.df[c]
cdata.fillna(inplace=True,method='bfill')
# This doesn't work because sometimes data are duplicated at save
cdata2 = savgol_filter(cdata.values,windowsize,3)
try:
cdata2 = savgol_filter(cdata.values,windowsize,3)
data[c] = cdata2
except ValueError:
data[c] = cdata
data[c] = cdata2
except (KeyError, AttributeError):
data[c] = 0

View File

@@ -2729,8 +2729,12 @@ def interactive_flex_chart2(id=0,promember=0,
xaxmax = rowdata['x1'].max()
xaxmin = rowdata['x1'].min()
else:
xaxmax = yaxmaxima[xparam]
xaxmin = yaxminima[xparam]
try:
xaxmax = yaxmaxima[xparam]
xaxmin = yaxminima[xparam]
except KeyError:
xaxmax = rowdata['x1'].max()
xaxmin = rowdata['x1'].min()
# average values
if xparam != 'time':
@@ -2766,8 +2770,10 @@ def interactive_flex_chart2(id=0,promember=0,
except KeyError:
y1mean = 0
rowdata['xname'] = axlabels[xparam]
try:
rowdata['xname'] = axlabels[xparam]
except KeyError:
rowdata['xname'] = xparam
try:
rowdata['yname1'] = axlabels[yparam1]
except KeyError:
@@ -2830,8 +2836,15 @@ def interactive_flex_chart2(id=0,promember=0,
line_dash=[6,6],line_width=2)
y2means = y1means
try:
xlabeltext = axlabels[xparam]+": {x1mean:6.2f}".format(
x1mean=x1mean
)
except KeyError:
xlabeltext = xparam+": {x1mean:6.2f}".format(x1mean=x1mean)
xlabel = Label(x=100,y=130,x_units='screen',y_units='screen',
text=axlabels[xparam]+": {x1mean:6.2f}".format(x1mean=x1mean),
text=xlabeltext,
background_fill_alpha=.7,
background_fill_color='white',
text_color='green',
@@ -2858,6 +2871,10 @@ def interactive_flex_chart2(id=0,promember=0,
except KeyError:
yaxlabel = str(yparam1)+' '
try:
xaxlabel = axlabels[xparam]
except KeyError:
xaxlabel = xparam
y1label = Label(x=100,y=100,x_units='screen',y_units='screen',
text=yaxlabel+": {y1mean:6.2f}".format(y1mean=y1mean),
@@ -2883,7 +2900,8 @@ def interactive_flex_chart2(id=0,promember=0,
plot.title.text = row.name
plot.title.text_font_size=value("1.0em")
plot.xaxis.axis_label = axlabels[xparam]
plot.xaxis.axis_label = xaxlabel
plot.yaxis.axis_label = yaxlabel

View File

@@ -5,6 +5,22 @@ import pandas as pd
from scipy import optimize
from django.utils import timezone
nometrics = [
'originalvelo',
'cumdist',
'strokes_slsh_min',
' WorkPerStroke (joules)',
' activityIdx',
' lapIdx',
# ' pointIdx',
' WorkoutType',
' IntervalType',
' WorkoutState',
' RowingState',
' WorkoutDurationType',
' WorkoutIntervalCount',
]
rowingmetrics = (
('time',{
'numtype':'float',

View File

@@ -70,6 +70,15 @@
<a class="button rosy small" href="/rowers/promembership">{{ value }}</a>
{% endfor %}
{% endif %}
{% if promember %}
{% for key, value in extrametrics.items %}
<a class="button orange small" href="/rowers/workout/{{ id }}/flexchart/{{ key }}/{{ yparam1 }}/{{ yparam2 }}/{{ plottype }}">{{ value }}</a>
{% endfor %}
{% else %}
{% for key, value in extrametrics.items %}
<a class="button rosy small" href="/rowers/promembership">{{ value }} (Pro)</a>
{% endfor %}
{% endif %}
</div>
</div>

View File

@@ -398,7 +398,7 @@ urlpatterns = [
url(r'^register/thankyou/$', TemplateView.as_view(template_name='registerthankyou.html'), name='registerthankyou'),
url(r'^workout/(?P<id>\d+)/workflow$',views.workout_workflow_view,
name='workout_workflow_view'),
url(r'^workout/(?P<id>\d+)/flexchart/(?P<xparam>\w+.*)/(?P<yparam1>[\w\ ]+.*)/(?P<yparam2>[\w\ ]+.*)/(?P<plottype>\w+)/$',views.workout_flexchart3_view),
url(r'^workout/(?P<id>\d+)/flexchart/(?P<xparam>[\w\ ]+.*)/(?P<yparam1>[\w\ ]+.*)/(?P<yparam2>[\w\ ]+.*)/(?P<plottype>\w+)/$',views.workout_flexchart3_view),
url(r'^workout/(?P<id>\d+)/flexchart/(?P<xparam>\w+.*)/(?P<yparam1>[\w\ ]+.*)/(?P<yparam2>[\w\ ]+.*)/(?P<plottype>\w+.*)$',views.workout_flexchart3_view),
url(r'^workout/(?P<id>\d+)/flexchart/(?P<xparam>\w+.*)/(?P<yparam1>[\w\ ]+.*)/(?P<yparam2>[\w\ ]+.*)$',views.workout_flexchart3_view),
url(r'^workout/(?P<id>\d+)/flexchart$',views.workout_flexchart3_view),

View File

@@ -8290,25 +8290,13 @@ def workout_flexchart3_view(request,*args,**kwargs):
yparam1 = yparam1.replace('/','_slsh_')
yparam2 = yparam2.replace('/','_slsh_')
try:
extrametrics.pop('originalvelo')
except KeyError:
pass
from rowers.metrics import nometrics
try:
extrametrics.pop('cumdist')
except KeyError:
pass
try:
extrametrics.pop(' Cadence (strokes_slsh_min)')
except KeyError:
pass
try:
extrametrics.pop(' WorkPerStroke (joules)')
except KeyError:
pass
for metric in nometrics:
try:
extrametrics.pop(metric)
except KeyError:
pass
return render(request,
'flexchart3otw.html',