next version interactive plot
This commit is contained in:
@@ -1859,12 +1859,13 @@ class FlexOptionsForm(forms.Form):
|
||||
|
||||
class ForceCurveOptionsForm(forms.Form):
|
||||
includereststrokes = forms.BooleanField(initial=False, required=False,
|
||||
label='Include Rest Strokes')
|
||||
label='Include Rest Strokes',
|
||||
widget=forms.CheckboxInput(attrs={'class':'hidden'}))
|
||||
|
||||
spm_min = forms.FloatField(initial=15.0,label='SPM Min',widget=HiddenInput,required=False)
|
||||
spm_max = forms.FloatField(initial=55.0,label='SPM Max',widget=HiddenInput,required=False)
|
||||
dist_min = forms.IntegerField(initial=0,label='Dist Min',widget=HiddenInput,required=False)
|
||||
dist_max = forms.IntegerField(initial=0,label='Dist Max',widget=HiddenInput,required=False)
|
||||
dist_max = forms.IntegerField(initial=150000,label='Dist Max',widget=HiddenInput,required=False)
|
||||
work_min = forms.IntegerField(initial=0,label='Work Min',widget=HiddenInput,required=False)
|
||||
work_max = forms.IntegerField(initial=1500,label='Work Max',widget=HiddenInput,required=False)
|
||||
|
||||
@@ -1872,6 +1873,13 @@ class ForceCurveOptionsForm(forms.Form):
|
||||
|
||||
name = forms.CharField(initial="", label='Name',required=False)
|
||||
|
||||
plotcircles = forms.BooleanField(initial=False,
|
||||
widget=forms.CheckboxInput(attrs={'class':'hidden'}),
|
||||
required=False)
|
||||
plotlines = forms.BooleanField(initial=False,
|
||||
widget=forms.CheckboxInput(attrs={'class':'hidden'}),
|
||||
required=False)
|
||||
|
||||
|
||||
axchoices = list(
|
||||
(ax[0], ax[1]) for ax in axes if ax[0] not in ['cumdist', 'None']
|
||||
|
||||
@@ -521,11 +521,7 @@ def interactive_activitychart2(workouts, startdate, enddate, stack='type',
|
||||
|
||||
return script, div
|
||||
|
||||
def interactive_forcecurve(theworkouts, workstrokesonly=True, plottype='scatter',
|
||||
spm_min=15, spm_max=45,
|
||||
notes='',
|
||||
dist_min=0,dist_max=0,
|
||||
work_min=0,work_max=1500):
|
||||
def interactive_forcecurve(theworkouts):
|
||||
TOOLS = 'save,pan,box_zoom,wheel_zoom,reset,tap,hover,crosshair'
|
||||
|
||||
ids = [int(w.id) for w in theworkouts]
|
||||
@@ -537,19 +533,11 @@ def interactive_forcecurve(theworkouts, workstrokesonly=True, plottype='scatter'
|
||||
'workoutstate', 'driveenergy', 'cumdist']
|
||||
|
||||
rowdata = dataprep.getsmallrowdata_db(columns, ids=ids,
|
||||
workstrokesonly=workstrokesonly)
|
||||
workstrokesonly=False)
|
||||
|
||||
rowdata.dropna(axis=1, how='all', inplace=True)
|
||||
rowdata.dropna(axis=0, how='any', inplace=True)
|
||||
|
||||
workoutstatesrest = [3]
|
||||
|
||||
if workstrokesonly:
|
||||
try:
|
||||
rowdata = rowdata[~rowdata['workoutstate'].isin(workoutstatesrest)]
|
||||
except KeyError: # pragma: no cover
|
||||
pass
|
||||
|
||||
if rowdata.empty:
|
||||
return "", "No Valid Data Available", "", ""
|
||||
|
||||
|
||||
@@ -5249,6 +5249,8 @@ class ForceCurveAnalysis(models.Model):
|
||||
average_spm = models.FloatField(default=23)
|
||||
average_boatspeed = models.FloatField(default=4.0)
|
||||
include_rest_strokes = models.BooleanField(default=False)
|
||||
plotcircles = models.BooleanField(default=False)
|
||||
plotlines = models.BooleanField(default=False)
|
||||
|
||||
def __str__(self):
|
||||
s = 'Force Curve Analysis {name} ({date})'.format(name = self.name,
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
<h1>Empower Force Curve</h1>
|
||||
|
||||
<ul class="main-content">
|
||||
<canvas hidden id="canvas"></canvas>
|
||||
<li class="grid_4">
|
||||
<div id="theplot" class="flexplot">
|
||||
{{ the_div|safe }}
|
||||
@@ -45,6 +46,13 @@
|
||||
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
var label = $('label[for="' + $("#id_plotcircles").attr('id') + '"]');
|
||||
label.attr("class", "hidden")
|
||||
var label2 = $('label[for="' + $("#id_plotlines").attr('id') + '"]');
|
||||
label2.attr("class", "hidden")
|
||||
var label3 = $('label[for="' + $("#id_includereststrokes").attr('id') + '"]');
|
||||
label3.attr("class", "hidden")
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -426,12 +426,14 @@ def workout_forcecurve_view(request, id=0, analysis=0, userid=0, workstrokesonly
|
||||
work_max = forceanalysis.work_max
|
||||
notes = forceanalysis.notes
|
||||
name = forceanalysis.name
|
||||
plotcircles = forceanalysis.plotcircles
|
||||
plotlines = forceanalysis.plotlines
|
||||
includereststrokes = forceanalysis.include_rest_strokes
|
||||
except (ForceCurveAnalysis.DoesNotExist, ValueError):
|
||||
pass
|
||||
else:
|
||||
dist_min = 0
|
||||
dist_max = 0
|
||||
dist_max = row.distance
|
||||
spm_min = 15
|
||||
spm_max = 55
|
||||
work_min = 0
|
||||
@@ -439,6 +441,8 @@ def workout_forcecurve_view(request, id=0, analysis=0, userid=0, workstrokesonly
|
||||
notes = ''
|
||||
includereststrokes = False
|
||||
name = ''
|
||||
plotcircles = True
|
||||
plotlines = False
|
||||
|
||||
form = ForceCurveOptionsForm(initial={
|
||||
'spm_min': spm_min,
|
||||
@@ -449,6 +453,8 @@ def workout_forcecurve_view(request, id=0, analysis=0, userid=0, workstrokesonly
|
||||
'work_max': work_max,
|
||||
'notes': notes,
|
||||
'name': name,
|
||||
'plotcircles': plotcircles,
|
||||
'plotlines': plotlines,
|
||||
})
|
||||
|
||||
|
||||
@@ -463,6 +469,8 @@ def workout_forcecurve_view(request, id=0, analysis=0, userid=0, workstrokesonly
|
||||
work_max = form.cleaned_data['work_max']
|
||||
notes = form.cleaned_data['notes']
|
||||
name = form.cleaned_data['name']
|
||||
plotlines = form.cleaned_data['plotlines']
|
||||
plotcircles = form.cleaned_data['plotcircles']
|
||||
if not name:
|
||||
name = row.name
|
||||
includereststrokes = form.cleaned_data['includereststrokes']
|
||||
@@ -482,6 +490,8 @@ def workout_forcecurve_view(request, id=0, analysis=0, userid=0, workstrokesonly
|
||||
spm_min = spm_min,
|
||||
spm_max = spm_max,
|
||||
rower=row.user,
|
||||
plotlines = plotlines,
|
||||
plotcircles = plotcircles,
|
||||
include_rest_strokes = includereststrokes,
|
||||
)
|
||||
else:
|
||||
@@ -495,6 +505,8 @@ def workout_forcecurve_view(request, id=0, analysis=0, userid=0, workstrokesonly
|
||||
forceanalysis.work_max = work_max
|
||||
forceanalysis.spm_min = spm_min
|
||||
forceanalysis.spm_max = spm_max
|
||||
forceanalysis.plotcircles = plotcircles
|
||||
forceanalysis.plotlines = plotlines
|
||||
forceanalysis.include_rest_strokes = includereststrokes
|
||||
forceanalysis.save()
|
||||
dosave = True
|
||||
@@ -523,15 +535,7 @@ def workout_forcecurve_view(request, id=0, analysis=0, userid=0, workstrokesonly
|
||||
|
||||
|
||||
script, div = interactive_forcecurve(
|
||||
[row],
|
||||
workstrokesonly=workstrokesonly,
|
||||
dist_min = dist_min,
|
||||
dist_max = dist_max,
|
||||
spm_min = spm_min,
|
||||
spm_max = spm_max,
|
||||
work_min = work_min,
|
||||
work_max = work_max,
|
||||
notes=notes,
|
||||
[row]
|
||||
)
|
||||
|
||||
breadcrumbs = [
|
||||
|
||||
Reference in New Issue
Block a user