adding extra parameters to X axis flex chart
This commit is contained in:
@@ -1686,9 +1686,13 @@ def getsmallrowdata_db(columns, ids=[], doclean=True, workstrokesonly=True):
|
|||||||
cdata = row.df[c]
|
cdata = row.df[c]
|
||||||
cdata.fillna(inplace=True,method='bfill')
|
cdata.fillna(inplace=True,method='bfill')
|
||||||
# This doesn't work because sometimes data are duplicated at save
|
# 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):
|
except (KeyError, AttributeError):
|
||||||
data[c] = 0
|
data[c] = 0
|
||||||
|
|||||||
@@ -2729,8 +2729,12 @@ def interactive_flex_chart2(id=0,promember=0,
|
|||||||
xaxmax = rowdata['x1'].max()
|
xaxmax = rowdata['x1'].max()
|
||||||
xaxmin = rowdata['x1'].min()
|
xaxmin = rowdata['x1'].min()
|
||||||
else:
|
else:
|
||||||
xaxmax = yaxmaxima[xparam]
|
try:
|
||||||
xaxmin = yaxminima[xparam]
|
xaxmax = yaxmaxima[xparam]
|
||||||
|
xaxmin = yaxminima[xparam]
|
||||||
|
except KeyError:
|
||||||
|
xaxmax = rowdata['x1'].max()
|
||||||
|
xaxmin = rowdata['x1'].min()
|
||||||
|
|
||||||
# average values
|
# average values
|
||||||
if xparam != 'time':
|
if xparam != 'time':
|
||||||
@@ -2766,8 +2770,10 @@ def interactive_flex_chart2(id=0,promember=0,
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
y1mean = 0
|
y1mean = 0
|
||||||
|
|
||||||
|
try:
|
||||||
rowdata['xname'] = axlabels[xparam]
|
rowdata['xname'] = axlabels[xparam]
|
||||||
|
except KeyError:
|
||||||
|
rowdata['xname'] = xparam
|
||||||
try:
|
try:
|
||||||
rowdata['yname1'] = axlabels[yparam1]
|
rowdata['yname1'] = axlabels[yparam1]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@@ -2830,8 +2836,15 @@ def interactive_flex_chart2(id=0,promember=0,
|
|||||||
line_dash=[6,6],line_width=2)
|
line_dash=[6,6],line_width=2)
|
||||||
y2means = y1means
|
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',
|
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_alpha=.7,
|
||||||
background_fill_color='white',
|
background_fill_color='white',
|
||||||
text_color='green',
|
text_color='green',
|
||||||
@@ -2858,6 +2871,10 @@ def interactive_flex_chart2(id=0,promember=0,
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
yaxlabel = str(yparam1)+' '
|
yaxlabel = str(yparam1)+' '
|
||||||
|
|
||||||
|
try:
|
||||||
|
xaxlabel = axlabels[xparam]
|
||||||
|
except KeyError:
|
||||||
|
xaxlabel = xparam
|
||||||
|
|
||||||
y1label = Label(x=100,y=100,x_units='screen',y_units='screen',
|
y1label = Label(x=100,y=100,x_units='screen',y_units='screen',
|
||||||
text=yaxlabel+": {y1mean:6.2f}".format(y1mean=y1mean),
|
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 = row.name
|
||||||
plot.title.text_font_size=value("1.0em")
|
plot.title.text_font_size=value("1.0em")
|
||||||
|
|
||||||
plot.xaxis.axis_label = axlabels[xparam]
|
|
||||||
|
plot.xaxis.axis_label = xaxlabel
|
||||||
|
|
||||||
plot.yaxis.axis_label = yaxlabel
|
plot.yaxis.axis_label = yaxlabel
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,22 @@ import pandas as pd
|
|||||||
from scipy import optimize
|
from scipy import optimize
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
|
nometrics = [
|
||||||
|
'originalvelo',
|
||||||
|
'cumdist',
|
||||||
|
'strokes_slsh_min',
|
||||||
|
' WorkPerStroke (joules)',
|
||||||
|
' activityIdx',
|
||||||
|
' lapIdx',
|
||||||
|
# ' pointIdx',
|
||||||
|
' WorkoutType',
|
||||||
|
' IntervalType',
|
||||||
|
' WorkoutState',
|
||||||
|
' RowingState',
|
||||||
|
' WorkoutDurationType',
|
||||||
|
' WorkoutIntervalCount',
|
||||||
|
]
|
||||||
|
|
||||||
rowingmetrics = (
|
rowingmetrics = (
|
||||||
('time',{
|
('time',{
|
||||||
'numtype':'float',
|
'numtype':'float',
|
||||||
|
|||||||
@@ -70,6 +70,15 @@
|
|||||||
<a class="button rosy small" href="/rowers/promembership">{{ value }}</a>
|
<a class="button rosy small" href="/rowers/promembership">{{ value }}</a>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% 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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -398,7 +398,7 @@ urlpatterns = [
|
|||||||
url(r'^register/thankyou/$', TemplateView.as_view(template_name='registerthankyou.html'), name='registerthankyou'),
|
url(r'^register/thankyou/$', TemplateView.as_view(template_name='registerthankyou.html'), name='registerthankyou'),
|
||||||
url(r'^workout/(?P<id>\d+)/workflow$',views.workout_workflow_view,
|
url(r'^workout/(?P<id>\d+)/workflow$',views.workout_workflow_view,
|
||||||
name='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\ ]+.*)/(?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/(?P<xparam>\w+.*)/(?P<yparam1>[\w\ ]+.*)/(?P<yparam2>[\w\ ]+.*)$',views.workout_flexchart3_view),
|
||||||
url(r'^workout/(?P<id>\d+)/flexchart$',views.workout_flexchart3_view),
|
url(r'^workout/(?P<id>\d+)/flexchart$',views.workout_flexchart3_view),
|
||||||
|
|||||||
@@ -8290,25 +8290,13 @@ def workout_flexchart3_view(request,*args,**kwargs):
|
|||||||
yparam1 = yparam1.replace('/','_slsh_')
|
yparam1 = yparam1.replace('/','_slsh_')
|
||||||
yparam2 = yparam2.replace('/','_slsh_')
|
yparam2 = yparam2.replace('/','_slsh_')
|
||||||
|
|
||||||
try:
|
from rowers.metrics import nometrics
|
||||||
extrametrics.pop('originalvelo')
|
|
||||||
except KeyError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
try:
|
for metric in nometrics:
|
||||||
extrametrics.pop('cumdist')
|
try:
|
||||||
except KeyError:
|
extrametrics.pop(metric)
|
||||||
pass
|
except KeyError:
|
||||||
|
pass
|
||||||
try:
|
|
||||||
extrametrics.pop(' Cadence (strokes_slsh_min)')
|
|
||||||
except KeyError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
try:
|
|
||||||
extrametrics.pop(' WorkPerStroke (joules)')
|
|
||||||
except KeyError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
return render(request,
|
return render(request,
|
||||||
'flexchart3otw.html',
|
'flexchart3otw.html',
|
||||||
|
|||||||
Reference in New Issue
Block a user