including time range
This commit is contained in:
@@ -153,6 +153,10 @@ class InstrokeForm(forms.Form):
|
||||
metric = forms.ChoiceField(label='metric',choices=(('a','a'),('b','b')))
|
||||
spm_min = forms.IntegerField(initial=15,label='SPM Min',widget=HiddenInput)
|
||||
spm_max = forms.IntegerField(initial=45,label='SPM Max',widget=HiddenInput)
|
||||
activeminutesmin = forms.IntegerField(
|
||||
required=False, initial=0, widget=forms.HiddenInput())
|
||||
activeminutesmax = forms.IntegerField(
|
||||
required=False, initial=0, widget=forms.HiddenInput())
|
||||
|
||||
def __init__(self, *args, **kwargs): # pragma: no cover
|
||||
choices = kwargs.pop('choices', [])
|
||||
|
||||
@@ -64,18 +64,40 @@ $( function() {
|
||||
max: 60,
|
||||
values: [ {{ spm_min }}, {{ spm_max }} ],
|
||||
slide: function( event, ui ) {
|
||||
$( "#amountspm" ).val(ui.values[ 0 ] + " - " + ui.values[ 1 ] );
|
||||
$( "#id_spm_min" ).val( ui.values[ 0 ]);
|
||||
$( "#id_spm_max" ).val(ui.values[ 1 ] );
|
||||
$( "#spm_min_info" ).text( ui.values[ 0 ]);
|
||||
$( "#spm_max_info" ).text(ui.values[ 1 ] );
|
||||
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
$( "#amountspm" ).val($( "#slider-range" ).slider( "values", 0 ) +
|
||||
" - " + $( "#slider-range" ).slider( "values", 1 ));
|
||||
|
||||
} );
|
||||
</script>
|
||||
<script>
|
||||
$("#instrokeform").mouseup(function() {
|
||||
submit_form();
|
||||
});
|
||||
|
||||
</script>
|
||||
<script>
|
||||
$( function() {
|
||||
console.log({{ activeminutesmin }}, {{ activeminutesmax}}, 'active range');
|
||||
$( "#slider-timerange" ).slider({
|
||||
range: true,
|
||||
min: 0,
|
||||
max: {{ maxminutes }},
|
||||
values: [ {{ activeminutesmin }}, {{ activeminutesmax }} ],
|
||||
slide: function( event, ui ) {
|
||||
$( "#amount" ).val(ui.values[ 0 ] + " min - " + ui.values[ 1 ] + " min " );
|
||||
$("#id_activeminutesmin").val(ui.values[0]);
|
||||
$("#id_activeminutesmax").val(ui.values[1]);
|
||||
}
|
||||
});
|
||||
$( "#amount" ).val($( "#slider-timerange" ).slider( "values", 0 ) +
|
||||
" min - " + $( "#slider-timerange" ).slider( "values", 1 ) + " min ");
|
||||
} );
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -97,6 +119,25 @@ $( function() {
|
||||
|
||||
<h1>In Stroke Metrics</h1>
|
||||
<ul class="main-content">
|
||||
<li class="grid_4">
|
||||
<form id="instrokeform" enctype="multipart/form-data" action="" method="post">
|
||||
{% csrf_token %}
|
||||
<table>
|
||||
{{ form.as_table }}
|
||||
</table>
|
||||
<div id="slider-range"></div>
|
||||
<p>
|
||||
<label for="amountspm">Active Range:</label>
|
||||
<input type="text" id="amountspm" readonly style="border:0; color:#1c75bc; font-weight:bold;">
|
||||
</p>
|
||||
<div id="slider-timerange"></div>
|
||||
<p>
|
||||
<label for="amount">Active Range:</label>
|
||||
<input type="text" id="amount" readonly style="border:0; color:#1c75bc; font-weight:bold;">
|
||||
</p>
|
||||
<input name='form' class="button" type="submit" value="Submit">
|
||||
</form>
|
||||
</li>
|
||||
<li class="grid_4">
|
||||
<div id="dd" class="flexplot">
|
||||
{{ dd|safe }}
|
||||
@@ -107,22 +148,6 @@ $( function() {
|
||||
{{ the_div|safe }}
|
||||
</div>
|
||||
</li>
|
||||
<li class="grid_4">
|
||||
<form id="instrokeform" enctype="multipart/form-data" action="" method="post">
|
||||
{% csrf_token %}
|
||||
<table>
|
||||
{{ form.as_table }}
|
||||
</table>
|
||||
<div id="slider-container">
|
||||
<span>SPM (slide to change):</span>
|
||||
<span id="spm_min_info">{{ spm_min }}</span>
|
||||
<span> - </span>
|
||||
<span id="spm_max_info">{{ spm_max }}</span>
|
||||
<hr id="slider-range" />
|
||||
</div>
|
||||
<input name='form' class="button" type="submit" value="Submit">
|
||||
</form>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
@@ -2934,26 +2934,40 @@ def instroke_chart_interactive(request, id=0):
|
||||
spm_min = 15
|
||||
spm_max = 45
|
||||
|
||||
activeminutesmax = int(rowdata.duration/60.)
|
||||
activeminutesmin = 0
|
||||
maxminutes = activeminutesmax
|
||||
|
||||
if request.method == 'POST':
|
||||
form = InstrokeForm(request.POST,choices=instrokemetrics)
|
||||
if form.is_valid():
|
||||
metric = form.cleaned_data['metric']
|
||||
spm_min = form.cleaned_data['spm_min']
|
||||
spm_max = form.cleaned_data['spm_max']
|
||||
activeminutesmin = form.cleaned_data['activeminutesmin']
|
||||
activeminutesmax = form.cleaned_data['activeminutesmax']
|
||||
|
||||
|
||||
data = rowdata.get_instroke_data(metric,
|
||||
activesecondsmin = 60.*activeminutesmin
|
||||
activesecondsmax = 60.*activeminutesmax
|
||||
|
||||
data = rowdata.get_instroke_data(
|
||||
metric,
|
||||
spm_min=spm_min,
|
||||
spm_max=spm_max)
|
||||
spm_max=spm_max,
|
||||
)
|
||||
|
||||
script, div = instroke_interactive_chart(data, metric, w,
|
||||
script, div = instroke_interactive_chart(
|
||||
data, metric, w,
|
||||
spm_min,
|
||||
spm_max)
|
||||
spm_max,
|
||||
)
|
||||
|
||||
# change to range spm_min to spm_max
|
||||
vals, units, typ = rowdata.updateinterval_metric(
|
||||
' Cadence (stokes/min)', spm_min, mode='larger',
|
||||
debug=False, smoothwindow=2.,)
|
||||
vals, units, typ = rowdata.updateinterval_range(
|
||||
' Cadence (stokes/min)', spm_min, spm_max,
|
||||
debug=False, smoothwindow=2.,
|
||||
activewindow=[activesecondsmin, activesecondsmax])
|
||||
|
||||
intervalstats = rowdata.allstats()
|
||||
itime, idist, itype = rowdata.intervalstats_values()
|
||||
@@ -3013,6 +3027,9 @@ def instroke_chart_interactive(request, id=0):
|
||||
'spm_max': spm_max,
|
||||
'ds': ds,
|
||||
'dd': dd,
|
||||
'activeminutesmin': activeminutesmin,
|
||||
'activeminutesmax': activeminutesmax,
|
||||
'maxminutes': maxminutes,
|
||||
})
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user