dynamic form for trendflex/boxplot combo
This commit is contained in:
@@ -2174,13 +2174,17 @@ def dataprep(rowdatadf, id=0, bands=True, barchart=True, otwpower=True,
|
|||||||
drivespeed = drivespeed.fillna(value=0)
|
drivespeed = drivespeed.fillna(value=0)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
driveenergy = rowdatadf['driveenergy']
|
print('driveenergy',rowdatadf['driveenergy'].mean())
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
print('KeyError')
|
||||||
if forceunit == 'lbs':
|
if forceunit == 'lbs':
|
||||||
driveenergy = drivelength * averageforce * lbstoN
|
driveenergy = drivelength * averageforce * lbstoN
|
||||||
else:
|
else:
|
||||||
drivenergy = drivelength * averageforce
|
drivenergy = drivelength * averageforce
|
||||||
|
|
||||||
|
if driveenergy.mean() == 0 and driveenergy.std() == 0:
|
||||||
|
driveenergy = 0*driveenergy+100
|
||||||
|
|
||||||
distance = rowdatadf.loc[:, 'cum_dist']
|
distance = rowdatadf.loc[:, 'cum_dist']
|
||||||
velo = 500. / p
|
velo = 500. / p
|
||||||
|
|
||||||
|
|||||||
@@ -820,45 +820,6 @@ class PlannedSessionMultipleCloneForm(forms.Form):
|
|||||||
label='Planned Sessions'
|
label='Planned Sessions'
|
||||||
)
|
)
|
||||||
|
|
||||||
analysischoices = (
|
|
||||||
('boxplot','Box Chart'),
|
|
||||||
('trendflex','Trend Flex'),
|
|
||||||
)
|
|
||||||
|
|
||||||
class AnalysisChoiceForm(forms.Form):
|
|
||||||
function = forms.ChoiceField(choices=analysischoices,initial='boxplot',
|
|
||||||
label='Analysis')
|
|
||||||
yparam = forms.ChoiceField(choices=parchoices,initial='spm',
|
|
||||||
label='Metric')
|
|
||||||
spmmin = forms.FloatField(initial=15,
|
|
||||||
required=False,label = 'Min SPM')
|
|
||||||
spmmax = forms.FloatField(initial=55,
|
|
||||||
required=False,label = 'Max SPM')
|
|
||||||
workmin = forms.FloatField(initial=0,
|
|
||||||
required=False,label = 'Min Work per Stroke')
|
|
||||||
workmax = forms.FloatField(initial=1500,
|
|
||||||
required=False,label = 'Max Work per Stroke')
|
|
||||||
|
|
||||||
includereststrokes = forms.BooleanField(initial=False,
|
|
||||||
required=False,
|
|
||||||
label='Include Rest Strokes')
|
|
||||||
|
|
||||||
|
|
||||||
class BoxPlotChoiceForm(forms.Form):
|
|
||||||
yparam = forms.ChoiceField(choices=parchoices,initial='spm',
|
|
||||||
label='Metric')
|
|
||||||
spmmin = forms.FloatField(initial=15,
|
|
||||||
required=False,label = 'Min SPM')
|
|
||||||
spmmax = forms.FloatField(initial=55,
|
|
||||||
required=False,label = 'Max SPM')
|
|
||||||
workmin = forms.FloatField(initial=0,
|
|
||||||
required=False,label = 'Min Work per Stroke')
|
|
||||||
workmax = forms.FloatField(initial=1500,
|
|
||||||
required=False,label = 'Max Work per Stroke')
|
|
||||||
|
|
||||||
includereststrokes = forms.BooleanField(initial=False,
|
|
||||||
required=False,
|
|
||||||
label='Include Rest Strokes')
|
|
||||||
|
|
||||||
grouplabels = axlabels.copy()
|
grouplabels = axlabels.copy()
|
||||||
grouplabels['date'] = 'Date'
|
grouplabels['date'] = 'Date'
|
||||||
@@ -876,6 +837,62 @@ from rowers.utils import palettes
|
|||||||
|
|
||||||
palettechoices = tuple((p,p) for p in palettes.keys())
|
palettechoices = tuple((p,p) for p in palettes.keys())
|
||||||
|
|
||||||
|
analysischoices = (
|
||||||
|
('boxplot','Box Chart'),
|
||||||
|
('trendflex','Trend Flex'),
|
||||||
|
)
|
||||||
|
|
||||||
|
class AnalysisChoiceForm(forms.Form):
|
||||||
|
function = forms.ChoiceField(choices=analysischoices,initial='boxplot',
|
||||||
|
label='Analysis')
|
||||||
|
plotfield = forms.ChoiceField(choices=parchoices,initial='spm',
|
||||||
|
label='Metric')
|
||||||
|
xparam = forms.ChoiceField(choices=parchoicesmultiflex,
|
||||||
|
initial='hr',
|
||||||
|
label='X axis')
|
||||||
|
yparam = forms.ChoiceField(choices=parchoicesmultiflex,
|
||||||
|
initial='pace',
|
||||||
|
label='Y axis')
|
||||||
|
groupby = forms.ChoiceField(choices=groupchoices,initial='spm',
|
||||||
|
label='Group By')
|
||||||
|
binsize = forms.FloatField(initial=1,required=False,label = 'Bin Size')
|
||||||
|
|
||||||
|
ploterrorbars = forms.BooleanField(initial=False,
|
||||||
|
required=False,
|
||||||
|
label='Plot Error Bars')
|
||||||
|
|
||||||
|
palette = forms.ChoiceField(choices=palettechoices,
|
||||||
|
label = 'Color Scheme',
|
||||||
|
initial='monochrome_blue')
|
||||||
|
|
||||||
|
spmmin = forms.FloatField(initial=15,
|
||||||
|
required=False,label = 'Min SPM')
|
||||||
|
spmmax = forms.FloatField(initial=55,
|
||||||
|
required=False,label = 'Max SPM')
|
||||||
|
workmin = forms.FloatField(initial=0,
|
||||||
|
required=False,label = 'Min Work per Stroke')
|
||||||
|
workmax = forms.FloatField(initial=1500,
|
||||||
|
required=False,label = 'Max Work per Stroke')
|
||||||
|
|
||||||
|
includereststrokes = forms.BooleanField(initial=False,
|
||||||
|
required=False,
|
||||||
|
label='Include Rest Strokes')
|
||||||
|
|
||||||
|
class BoxPlotChoiceForm(forms.Form):
|
||||||
|
yparam = forms.ChoiceField(choices=parchoices,initial='spm',
|
||||||
|
label='Metric')
|
||||||
|
spmmin = forms.FloatField(initial=15,
|
||||||
|
required=False,label = 'Min SPM')
|
||||||
|
spmmax = forms.FloatField(initial=55,
|
||||||
|
required=False,label = 'Max SPM')
|
||||||
|
workmin = forms.FloatField(initial=0,
|
||||||
|
required=False,label = 'Min Work per Stroke')
|
||||||
|
workmax = forms.FloatField(initial=1500,
|
||||||
|
required=False,label = 'Max Work per Stroke')
|
||||||
|
|
||||||
|
includereststrokes = forms.BooleanField(initial=False,
|
||||||
|
required=False,
|
||||||
|
label='Include Rest Strokes')
|
||||||
|
|
||||||
class MultiFlexChoiceForm(forms.Form):
|
class MultiFlexChoiceForm(forms.Form):
|
||||||
xparam = forms.ChoiceField(choices=parchoicesmultiflex,
|
xparam = forms.ChoiceField(choices=parchoicesmultiflex,
|
||||||
|
|||||||
@@ -63,6 +63,78 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// script for chart options form
|
||||||
|
$(function() {
|
||||||
|
|
||||||
|
// Get the form fields and hidden div
|
||||||
|
var functionfield = $("#id_function");
|
||||||
|
var plotfield = $("#id_plotfield").parent().parent();
|
||||||
|
var x_param = $("#id_xparam").parent().parent();
|
||||||
|
var y_param = $("#id_yparam").parent().parent();
|
||||||
|
var groupby = $("#id_groupby").parent().parent();
|
||||||
|
var binsize = $("#id_binsize").parent().parent();
|
||||||
|
var errorbars = $("#id_ploterrorbars").parent().parent();
|
||||||
|
var palette = $("#id_palette").parent().parent();
|
||||||
|
|
||||||
|
|
||||||
|
// Hide the fields.
|
||||||
|
// Use JS to do this in case the user doesn't have JS
|
||||||
|
// enabled.
|
||||||
|
plotfield.hide();
|
||||||
|
x_param.hide();
|
||||||
|
y_param.hide();
|
||||||
|
groupby.hide();
|
||||||
|
errorbars.hide();
|
||||||
|
palette.hide();
|
||||||
|
binsize.hide();
|
||||||
|
|
||||||
|
if (functionfield.val() == 'boxplot') {
|
||||||
|
plotfield.show();
|
||||||
|
};
|
||||||
|
|
||||||
|
if (functionfield.val() == 'trendflex') {
|
||||||
|
x_param.show();
|
||||||
|
y_param.show();
|
||||||
|
groupby.show();
|
||||||
|
palette.show();
|
||||||
|
binsize.show();
|
||||||
|
errorbars.show();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Setup an event listener for when the state of the
|
||||||
|
// checkbox changes.
|
||||||
|
functionfield.change(function() {
|
||||||
|
// Check to see if the checkbox is checked.
|
||||||
|
// If it is, show the fields and populate the input.
|
||||||
|
// If not, hide the fields.
|
||||||
|
var Value = functionfield.val();
|
||||||
|
if (Value=='boxplot') {
|
||||||
|
// Show the hidden fields.
|
||||||
|
plotfield.show();
|
||||||
|
x_param.hide();
|
||||||
|
y_param.hide();
|
||||||
|
groupby.hide();
|
||||||
|
palette.hide();
|
||||||
|
binsize.hide();
|
||||||
|
errorbars.hide();
|
||||||
|
}
|
||||||
|
else if (Value=='trendflex') {
|
||||||
|
x_param.show();
|
||||||
|
y_param.show();
|
||||||
|
groupby.show();
|
||||||
|
palette.show();
|
||||||
|
binsize.show();
|
||||||
|
errorbars.show();
|
||||||
|
plotfield.hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
<script src="https://cdn.pydata.org/bokeh/release/bokeh-1.0.4.min.js"></script>
|
<script src="https://cdn.pydata.org/bokeh/release/bokeh-1.0.4.min.js"></script>
|
||||||
<script async="true" type="text/javascript">
|
<script async="true" type="text/javascript">
|
||||||
Bokeh.set_log_level("info");
|
Bokeh.set_log_level("info");
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ def analysis_new(request,userid=0,function='boxplot'):
|
|||||||
for key, value in chartform.cleaned_data.items():
|
for key, value in chartform.cleaned_data.items():
|
||||||
options[key] = value
|
options[key] = value
|
||||||
|
|
||||||
|
|
||||||
form = WorkoutMultipleCompareForm(request.POST)
|
form = WorkoutMultipleCompareForm(request.POST)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
cd = form.cleaned_data
|
cd = form.cleaned_data
|
||||||
@@ -216,7 +217,8 @@ def analysis_new(request,userid=0,function='boxplot'):
|
|||||||
|
|
||||||
|
|
||||||
def boxplotdata(workouts,options):
|
def boxplotdata(workouts,options):
|
||||||
try:
|
|
||||||
|
|
||||||
includereststrokes = options['includereststrokes']
|
includereststrokes = options['includereststrokes']
|
||||||
spmmin = options['spmmin']
|
spmmin = options['spmmin']
|
||||||
spmmax = options['spmmax']
|
spmmax = options['spmmax']
|
||||||
@@ -226,17 +228,6 @@ def boxplotdata(workouts,options):
|
|||||||
userid = options['userid']
|
userid = options['userid']
|
||||||
plotfield = options['plotfield']
|
plotfield = options['plotfield']
|
||||||
function = options['function']
|
function = options['function']
|
||||||
except KeyError:
|
|
||||||
includereststrokes = False
|
|
||||||
spmmin = 15
|
|
||||||
spmmax = 55
|
|
||||||
workmin = 0
|
|
||||||
workmax = 55
|
|
||||||
ids = []
|
|
||||||
userid = 0
|
|
||||||
plotfield = 'spm'
|
|
||||||
function = 'boxplot'
|
|
||||||
|
|
||||||
|
|
||||||
workstrokesonly = not includereststrokes
|
workstrokesonly = not includereststrokes
|
||||||
labeldict = {
|
labeldict = {
|
||||||
|
|||||||
Reference in New Issue
Block a user