next version interactive plot
This commit is contained in:
@@ -1859,12 +1859,13 @@ class FlexOptionsForm(forms.Form):
|
|||||||
|
|
||||||
class ForceCurveOptionsForm(forms.Form):
|
class ForceCurveOptionsForm(forms.Form):
|
||||||
includereststrokes = forms.BooleanField(initial=False, required=False,
|
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_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)
|
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_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_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)
|
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)
|
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(
|
axchoices = list(
|
||||||
(ax[0], ax[1]) for ax in axes if ax[0] not in ['cumdist', 'None']
|
(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
|
return script, div
|
||||||
|
|
||||||
def interactive_forcecurve(theworkouts, workstrokesonly=True, plottype='scatter',
|
def interactive_forcecurve(theworkouts):
|
||||||
spm_min=15, spm_max=45,
|
|
||||||
notes='',
|
|
||||||
dist_min=0,dist_max=0,
|
|
||||||
work_min=0,work_max=1500):
|
|
||||||
TOOLS = 'save,pan,box_zoom,wheel_zoom,reset,tap,hover,crosshair'
|
TOOLS = 'save,pan,box_zoom,wheel_zoom,reset,tap,hover,crosshair'
|
||||||
|
|
||||||
ids = [int(w.id) for w in theworkouts]
|
ids = [int(w.id) for w in theworkouts]
|
||||||
@@ -537,19 +533,11 @@ def interactive_forcecurve(theworkouts, workstrokesonly=True, plottype='scatter'
|
|||||||
'workoutstate', 'driveenergy', 'cumdist']
|
'workoutstate', 'driveenergy', 'cumdist']
|
||||||
|
|
||||||
rowdata = dataprep.getsmallrowdata_db(columns, ids=ids,
|
rowdata = dataprep.getsmallrowdata_db(columns, ids=ids,
|
||||||
workstrokesonly=workstrokesonly)
|
workstrokesonly=False)
|
||||||
|
|
||||||
rowdata.dropna(axis=1, how='all', inplace=True)
|
rowdata.dropna(axis=1, how='all', inplace=True)
|
||||||
rowdata.dropna(axis=0, how='any', 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:
|
if rowdata.empty:
|
||||||
return "", "No Valid Data Available", "", ""
|
return "", "No Valid Data Available", "", ""
|
||||||
|
|
||||||
|
|||||||
@@ -5249,6 +5249,8 @@ class ForceCurveAnalysis(models.Model):
|
|||||||
average_spm = models.FloatField(default=23)
|
average_spm = models.FloatField(default=23)
|
||||||
average_boatspeed = models.FloatField(default=4.0)
|
average_boatspeed = models.FloatField(default=4.0)
|
||||||
include_rest_strokes = models.BooleanField(default=False)
|
include_rest_strokes = models.BooleanField(default=False)
|
||||||
|
plotcircles = models.BooleanField(default=False)
|
||||||
|
plotlines = models.BooleanField(default=False)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
s = 'Force Curve Analysis {name} ({date})'.format(name = self.name,
|
s = 'Force Curve Analysis {name} ({date})'.format(name = self.name,
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
<h1>Empower Force Curve</h1>
|
<h1>Empower Force Curve</h1>
|
||||||
|
|
||||||
<ul class="main-content">
|
<ul class="main-content">
|
||||||
|
<canvas hidden id="canvas"></canvas>
|
||||||
<li class="grid_4">
|
<li class="grid_4">
|
||||||
<div id="theplot" class="flexplot">
|
<div id="theplot" class="flexplot">
|
||||||
{{ the_div|safe }}
|
{{ the_div|safe }}
|
||||||
@@ -45,6 +46,13 @@
|
|||||||
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
|
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(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>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -426,12 +426,14 @@ def workout_forcecurve_view(request, id=0, analysis=0, userid=0, workstrokesonly
|
|||||||
work_max = forceanalysis.work_max
|
work_max = forceanalysis.work_max
|
||||||
notes = forceanalysis.notes
|
notes = forceanalysis.notes
|
||||||
name = forceanalysis.name
|
name = forceanalysis.name
|
||||||
|
plotcircles = forceanalysis.plotcircles
|
||||||
|
plotlines = forceanalysis.plotlines
|
||||||
includereststrokes = forceanalysis.include_rest_strokes
|
includereststrokes = forceanalysis.include_rest_strokes
|
||||||
except (ForceCurveAnalysis.DoesNotExist, ValueError):
|
except (ForceCurveAnalysis.DoesNotExist, ValueError):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
dist_min = 0
|
dist_min = 0
|
||||||
dist_max = 0
|
dist_max = row.distance
|
||||||
spm_min = 15
|
spm_min = 15
|
||||||
spm_max = 55
|
spm_max = 55
|
||||||
work_min = 0
|
work_min = 0
|
||||||
@@ -439,6 +441,8 @@ def workout_forcecurve_view(request, id=0, analysis=0, userid=0, workstrokesonly
|
|||||||
notes = ''
|
notes = ''
|
||||||
includereststrokes = False
|
includereststrokes = False
|
||||||
name = ''
|
name = ''
|
||||||
|
plotcircles = True
|
||||||
|
plotlines = False
|
||||||
|
|
||||||
form = ForceCurveOptionsForm(initial={
|
form = ForceCurveOptionsForm(initial={
|
||||||
'spm_min': spm_min,
|
'spm_min': spm_min,
|
||||||
@@ -449,6 +453,8 @@ def workout_forcecurve_view(request, id=0, analysis=0, userid=0, workstrokesonly
|
|||||||
'work_max': work_max,
|
'work_max': work_max,
|
||||||
'notes': notes,
|
'notes': notes,
|
||||||
'name': name,
|
'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']
|
work_max = form.cleaned_data['work_max']
|
||||||
notes = form.cleaned_data['notes']
|
notes = form.cleaned_data['notes']
|
||||||
name = form.cleaned_data['name']
|
name = form.cleaned_data['name']
|
||||||
|
plotlines = form.cleaned_data['plotlines']
|
||||||
|
plotcircles = form.cleaned_data['plotcircles']
|
||||||
if not name:
|
if not name:
|
||||||
name = row.name
|
name = row.name
|
||||||
includereststrokes = form.cleaned_data['includereststrokes']
|
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_min = spm_min,
|
||||||
spm_max = spm_max,
|
spm_max = spm_max,
|
||||||
rower=row.user,
|
rower=row.user,
|
||||||
|
plotlines = plotlines,
|
||||||
|
plotcircles = plotcircles,
|
||||||
include_rest_strokes = includereststrokes,
|
include_rest_strokes = includereststrokes,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
@@ -495,6 +505,8 @@ def workout_forcecurve_view(request, id=0, analysis=0, userid=0, workstrokesonly
|
|||||||
forceanalysis.work_max = work_max
|
forceanalysis.work_max = work_max
|
||||||
forceanalysis.spm_min = spm_min
|
forceanalysis.spm_min = spm_min
|
||||||
forceanalysis.spm_max = spm_max
|
forceanalysis.spm_max = spm_max
|
||||||
|
forceanalysis.plotcircles = plotcircles
|
||||||
|
forceanalysis.plotlines = plotlines
|
||||||
forceanalysis.include_rest_strokes = includereststrokes
|
forceanalysis.include_rest_strokes = includereststrokes
|
||||||
forceanalysis.save()
|
forceanalysis.save()
|
||||||
dosave = True
|
dosave = True
|
||||||
@@ -523,15 +535,7 @@ def workout_forcecurve_view(request, id=0, analysis=0, userid=0, workstrokesonly
|
|||||||
|
|
||||||
|
|
||||||
script, div = interactive_forcecurve(
|
script, div = interactive_forcecurve(
|
||||||
[row],
|
[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,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
breadcrumbs = [
|
breadcrumbs = [
|
||||||
|
|||||||
Reference in New Issue
Block a user