Private
Public Access
1
0

added flexall

This commit is contained in:
Sander Roosendaal
2019-04-29 20:34:59 +02:00
parent a670ee0884
commit 256dd25df2
3 changed files with 114 additions and 5 deletions

View File

@@ -841,11 +841,39 @@ analysischoices = (
('boxplot','Box Chart'), ('boxplot','Box Chart'),
('trendflex','Trend Flex'), ('trendflex','Trend Flex'),
('histo','Histogram'), ('histo','Histogram'),
('flexall','Cumulative Flex Chart')
) )
class AnalysisChoiceForm(forms.Form): class AnalysisChoiceForm(forms.Form):
axchoices = list(
(ax[0],ax[1]) for ax in axes if ax[0] not in ['cumdist','None']
)
axchoices = dict((x,y) for x,y in axchoices)
axchoices = list(sorted(axchoices.items(), key = lambda x:x[1]))
yaxchoices = list((ax[0],ax[1]) for ax in axes if ax[0] not in ['cumdist','distance','time'])
yaxchoices = dict((x,y) for x,y in yaxchoices)
yaxchoices = list(sorted(yaxchoices.items(), key = lambda x:x[1]))
yaxchoices2 = list(
(ax[0],ax[1]) for ax in axes if ax[0] not in ['cumdist','distance','time']
)
yaxchoices2 = dict((x,y) for x,y in yaxchoices2)
yaxchoices2 = list(sorted(yaxchoices2.items(), key = lambda x:x[1]))
function = forms.ChoiceField(choices=analysischoices,initial='boxplot', function = forms.ChoiceField(choices=analysischoices,initial='boxplot',
label='Analysis') label='Analysis')
xaxis = forms.ChoiceField(
choices=axchoices,label='X-Axis',required=True,initial='spm')
yaxis1 = forms.ChoiceField(
choices=yaxchoices,label='Left Axis',required=True,initial='power')
yaxis2 = forms.ChoiceField(
choices=yaxchoices2,label='Right Axis',required=True,initial='None')
plotfield = forms.ChoiceField(choices=parchoices,initial='spm', plotfield = forms.ChoiceField(choices=parchoices,initial='spm',
label='Metric') label='Metric')
xparam = forms.ChoiceField(choices=parchoicesmultiflex, xparam = forms.ChoiceField(choices=parchoicesmultiflex,
@@ -854,6 +882,7 @@ class AnalysisChoiceForm(forms.Form):
yparam = forms.ChoiceField(choices=parchoicesmultiflex, yparam = forms.ChoiceField(choices=parchoicesmultiflex,
initial='pace', initial='pace',
label='Y axis') label='Y axis')
groupby = forms.ChoiceField(choices=groupchoices,initial='spm', groupby = forms.ChoiceField(choices=groupchoices,initial='spm',
label='Group By') label='Group By')
binsize = forms.FloatField(initial=1,required=False,label = 'Bin Size') binsize = forms.FloatField(initial=1,required=False,label = 'Bin Size')

View File

@@ -72,12 +72,20 @@
var plotfield = $("#id_plotfield").parent().parent(); var plotfield = $("#id_plotfield").parent().parent();
var x_param = $("#id_xparam").parent().parent(); var x_param = $("#id_xparam").parent().parent();
var y_param = $("#id_yparam").parent().parent(); var y_param = $("#id_yparam").parent().parent();
var groupby = $("#id_groupby").parent().parent(); var groupby = $("#id_groupby").parent().parent();
var binsize = $("#id_binsize").parent().parent(); var binsize = $("#id_binsize").parent().parent();
var errorbars = $("#id_ploterrorbars").parent().parent(); var errorbars = $("#id_ploterrorbars").parent().parent();
var palette = $("#id_palette").parent().parent(); var palette = $("#id_palette").parent().parent();
var spmmin = $("#id_spmmin").parent().parent();
var spmmax = $("#id_spmmax").parent().parent();
var workmin = $("#id_workmin").parent().parent();
var workmax = $("#id_workmax").parent().parent();
var xaxis = $("#id_xaxis").parent().parent();
var yaxis1 = $("#id_yaxis1").parent().parent();
var yaxis2 = $("#id_yaxis2").parent().parent();
// Hide the fields. // Hide the fields.
// Use JS to do this in case the user doesn't have JS // Use JS to do this in case the user doesn't have JS
// enabled. // enabled.
@@ -88,6 +96,9 @@
errorbars.hide(); errorbars.hide();
palette.hide(); palette.hide();
binsize.hide(); binsize.hide();
xaxis.hide();
yaxis1.hide();
yaxis2.hide();
if (functionfield.val() == 'boxplot') { if (functionfield.val() == 'boxplot') {
plotfield.show(); plotfield.show();
@@ -95,7 +106,7 @@
if (functionfield.val() == 'histo') { if (functionfield.val() == 'histo') {
plotfield.show() plotfield.show()
} };
if (functionfield.val() == 'trendflex') { if (functionfield.val() == 'trendflex') {
x_param.show(); x_param.show();
@@ -106,6 +117,12 @@
errorbars.show(); errorbars.show();
}; };
if (functionfield.val() == 'flexall') {
xaxis.show();
yaxis1.show();
yaxis2.show();
}
// Setup an event listener for when the state of the // Setup an event listener for when the state of the
// checkbox changes. // checkbox changes.
@@ -117,21 +134,36 @@
if (Value=='boxplot') { if (Value=='boxplot') {
// Show the hidden fields. // Show the hidden fields.
plotfield.show(); plotfield.show();
spmmin.show();
spmmax.show();
workmin.show();
workmax.show();
x_param.hide(); x_param.hide();
y_param.hide(); y_param.hide();
groupby.hide(); groupby.hide();
palette.hide(); palette.hide();
binsize.hide(); binsize.hide();
errorbars.hide(); errorbars.hide();
xaxis.hide();
yaxis1.hide();
yaxis2.hide();
} }
else if (Value=='histo') { else if (Value=='histo') {
plotfield.show(); plotfield.show();
spmmin.show();
spmmax.show();
workmin.show();
workmax.show();
x_param.hide(); x_param.hide();
y_param.hide(); y_param.hide();
groupby.hide(); groupby.hide();
palette.hide(); palette.hide();
binsize.hide(); binsize.hide();
errorbars.hide(); errorbars.hide();
xaxis.hide();
yaxis1.hide();
yaxis2.hide();
} }
else if (Value=='trendflex') { else if (Value=='trendflex') {
x_param.show(); x_param.show();
@@ -140,12 +172,35 @@
palette.show(); palette.show();
binsize.show(); binsize.show();
errorbars.show(); errorbars.show();
spmmin.show();
spmmax.show();
workmin.show();
workmax.show();
plotfield.hide(); plotfield.hide();
xaxis.hide();
yaxis1.hide();
yaxis2.hide();
}
else if (Value=='flexall') {
xaxis.show();
yaxis1.show();
yaxis2.show();
x_param.hide();
y_param.hide();
groupby.hide();
spmmin.hide();
spmmax.hide();
workmin.hide();
workmax.hide();
plotfield.hide();
palette.hide();
binsize.hide();
errorbars.hide();
} }
}); });
});
});
</script> </script>
<div id="id_css_res"> <div id="id_css_res">

View File

@@ -415,6 +415,29 @@ def trendflexdata(workouts, options,userid=0):
return(script,div) return(script,div)
def flexalldata(workouts, options):
includereststrokes = options['includereststrokes']
xparam = options['xaxis']
yparam1 = options['yaxis1']
yparam2 = options['yaxis2']
promember=True
workstrokesonly = not includereststrokes
res = interactive_cum_flex_chart2(workouts, xparam=xparam,
yparam1=yparam1,
yparam2=yparam2,
promember=promember,
workstrokesonly=workstrokesonly,
)
script = res[0]
div = res[1]
scripta = script.split('\n')[2:-1]
script = ''.join(scripta)
return(script,div)
def histodata(workouts, options): def histodata(workouts, options):
includereststrokes = options['includereststrokes'] includereststrokes = options['includereststrokes']
plotfield = options['plotfield'] plotfield = options['plotfield']
@@ -545,6 +568,8 @@ def analysis_view_data(request,userid=0):
script, div = trendflexdata(workouts, options,userid=userid) script, div = trendflexdata(workouts, options,userid=userid)
elif function == 'histo': elif function == 'histo':
script, div = histodata(workouts, options) script, div = histodata(workouts, options)
elif function == 'flexall':
script,div = flexalldata(workouts,options)
else: else:
script = '' script = ''
div = 'Unknown analysis functions' div = 'Unknown analysis functions'