Private
Public Access
1
0
This commit is contained in:
Sander Roosendaal
2018-10-08 15:20:11 +02:00
parent b0748831ad
commit 9025a0d8dc
5 changed files with 258 additions and 425 deletions

View File

@@ -1,17 +1,16 @@
{% extends "base.html" %}
{% extends "newbase.html" %}
{% load staticfiles %}
{% load rowerfilters %}
{% block title %}Workout Statistics{% endblock %}
{% block content %}
{% block title %}Rowsandall {% endblock %}
{% block main %}
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
<script>
$(function() {
// Get the form fields and hidden div
var checkbox = $("#id_water");
var modality = $("#id_modality");
var hidden = $("#id_waterboattype");
@@ -20,15 +19,20 @@
// enabled.
hidden.hide();
if (modality.val() == 'water') {
hidden.show();
}
// Setup an event listener for when the state of the
// checkbox changes.
checkbox.change(function() {
modality.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.
if (checkbox.is(':checked')) {
// If not, hide the fields.
var Value = modality.val();
if (Value=='water') {
// Show the hidden fields.
hidden.show();
} else {
@@ -46,168 +50,93 @@
// $("#hidden_field").val("");
}
});
});
});
</script>
<script type="text/javascript" src="/static/js/bokeh-0.12.3.min.js"></script>
<script async="true" type="text/javascript">
Bokeh.set_log_level("info");
</script>
{{ plotscript |safe }}
<script>
// Set things up to resize the plot on a window resize. You can play with
// the arguments of resize_width_height() to change the plot's behavior.
var plot_resize_setup = function () {
var plotid = Object.keys(Bokeh.index)[0]; // assume we have just one plot
var plot = Bokeh.index[plotid];
var plotresizer = function() {
// arguments: use width, use height, maintain aspect ratio
plot.resize_width_height(true, true, true);
};
window.addEventListener('resize', plotresizer);
plotresizer();
};
window.addEventListener('load', plot_resize_setup);
</script>
<style>
/* Need this to get the page in "desktop mode"; not having an infinite height.*/
html, body {height: 100%; margin:5px;}
</style>
<div class="grid_12 alpha">
<div class="grid_4 alpha">
{% if theuser %}
<h3>{{ theuser.first_name }}'s Workout Statistics</h3>
{% else %}
<h3>{{ user.first_name }}'s Workout Statistics</h3>
{% endif %}
</div>
<div class="grid_2 suffix_6 omega">
{% if user.is_authenticated and user|is_manager %}
<div class="grid_2 alpha dropdown">
<button class="grid_2 alpha button green small dropbtn">
{{ theuser.first_name }} {{ theuser.last_name }}
</button>
<div class="dropdown-content">
{% for member in user|team_members %}
<a class="button green small" href="/rowers/{{ member.id }}/cumstats/{{ startdate|date:"Y-m-d" }}/{{ enddate|date:"Y-m-d" }}/p/{{ plotfield }}">{{ member.first_name }} {{ member.last_name }}</a>
{% endfor %}
</div>
{% else %}
&nbsp;
{% endif %}
</div>
<div id="id_css_res">
<link rel="stylesheet" href="/static/css/bokeh-0.12.3.min.css" type="text/css" />
<link rel="stylesheet" href="/static/css/bokeh-widgets-0.12.3.min.css" type="text/css" />
</div>
<div class="grid_12 alpha">
<div id="summary" class="grid_6 alpha">
<p>Summary for {{ theuser.first_name }} {{ theuser.last_name }}
between {{ startdate|date }} and {{ enddate|date }}</p>
<p>Direct link for other Pro users:
<a href="/rowers/{{ id }}/cumstats/{{ startdate|date:"Y-m-d" }}/{{ enddate|date:"Y-m-d" }}/p/{{ plotfield }}">https://rowsandall.com/rowers/{{ id }}/cumstats/{{ startdate|date:"Y-m-d" }}/{{ enddate|date:"Y-m-d" }}/p/{{ plotfield }}</a>
</p>
<form enctype="multipart/form-data" action="{{ formloc }}" method="post">
{% csrf_token %}
<div class="grid_2 alpha">
<table>
{{ optionsform.as_table }}
</table>
</div>
<div class="grid_2 suffix_2 omega">
<input type="hidden" name="options" value="options">
<input class="grid_1 alpha button green small" value="Submit" type="Submit">
</div>
</form>
<div id="id_js_res">
<script
type="text/javascript" src="/static/js/bokeh-0.12.3.min.js">
</script>
<script
type="text/javascript" src="/static/js/bokeh-widgets-0.12.3.min.js">
</script>
</div>
<div id="form" class="grid_6 omega">
<p>Use this form to select a different date range:</p>
<p>
Select start and end date for a date range:
<div class="grid_4 alpha">
<form enctype="multipart/form-data" action="" method="post">
<table>
{{ form.as_table }}
</table>
{% csrf_token %}
</div>
<div class="grid_2 omega">
<input name='daterange' class="button green" type="submit" value="Submit"> </form>
</div>
<div class="grid_4 alpha">
<form enctype="multipart/form-data" action="" method="post">
Or use the last {{ deltaform }} days.
</div>
<div class="grid_2 omega">
{% csrf_token %}
<input name='datedelta' class="button green" type="submit" value="Submit">
</form>
</div>
</div>
</div>
<div class="grid_12 alpha">
<div class="grid_4 alpha">
{% if stats %}
{% for key, value in stats.items %}
<h2>{{ value.verbosename }}</h2>
<div class="grid_1">
<p>
<a class="button blue small" href="/rowers/{{ id }}/cumstats/{{ startdate|date:"Y-m-d" }}/{{ enddate|date:"Y-m-d" }}/p/{{ key }}">Plot</a>
</p>
</div>
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
<div id="id_script">
</div>
<ul class="main-content">
<li class="grid_4">
<p>Summary for {{ theuser.first_name }} {{ theuser.last_name }}
between {{ startdate|date }} and {{ enddate|date }}</p>
</li>
<li class="grid_4">
{% if stats %}
<h2>Statistics</h2>
<table width="100%" class="listtable">
<thead>
<tr>
<th>Metric</th>
<th>Value</th>
<th>Mean</th>
<th>Minimum</th>
<th>25&#37;</th>
<th>Median</th>
<th>75&#37;</th>
<th>Maximum</th>
<th>Standard Deviation</th>
</tr>
</thead>
<tbody>
{% for key, value in stats.items %}
<tr>
<td>Mean</td><td>{{ value.mean|floatformat:-2 }}</td>
</tr><tr>
<td>Minimum</td><td>{{ value.min|floatformat:-2 }}</td>
</tr><tr>
<td>25&#37;</td><td>{{ value.firstq|floatformat:-2 }}</td>
</tr><tr>
<td>Median</td><td>{{ value.median|floatformat:-2 }}</td>
</tr><tr>
<td>75&#37;</td><td>{{ value.thirdq|floatformat:-2 }}</td>
</tr><tr>
<td>Maximum</td><td>{{ value.max|floatformat:-2 }}</td>
</tr><tr>
<td>Standard Deviation</td><td>{{ value.std|floatformat:-2 }}</td>
<td>{{ value.verbosename }}</td>
<td>{{ value.mean|floatformat:-2 }}</td>
<td>{{ value.min|floatformat:-2 }}</td>
<td>{{ value.firstq|floatformat:-2 }}</td>
<td>{{ value.median|floatformat:-2 }}</td>
<td>{{ value.thirdq|floatformat:-2 }}</td>
<td>{{ value.max|floatformat:-2 }}</td>
<td>{{ value.std|floatformat:-2 }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endfor %}
{% endif %}
</div>
<div class="grid_8 omega">
{% if cordict %}
<div class="grid_8">
<h2> Correlation Matrix</h2>
<p>This matrix indicates a positive (+) or negative (-) correlation between two parameters. The Spearman correlation coefficient has values between +1 and -1. Positive correlation between two metrics means that if one metric increases, the other value is also likely to increase. Negative is the opposite. The further from zero, the higher the likelyhood.
{% endif %}
</li>
<li class="grid_4">
{% if cordict %}
<h2> Correlation matrix</h2>
<p>This matrix indicates a positive (+) or negative (-) correlation between two parameters. The Spearman correlation coefficient has values between +1 and -1. Positive correlation between two metrics means that if one metric increases, the other value is also likely to increase. Negative is the opposite. The further from zero, the higher the likelyhood.
</p>
<table width="90%" class="cortable">
<thead>
<tr>
<th>&nbsp;</th>
{% for key,value in cordict.items %}
<th class="rotate"><div><span>{{ key }}</span></div></th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for key, thedict in cordict.items %}
<table width="90%" class="cortable">
<thead>
<tr>
<th>&nbsp;</th>
{% for key,value in cordict.items %}
<th class="rotate"><div><span>{{ key }}</span></div></th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for key, thedict in cordict.items %}
<tr>
<th> {{ key }}</th>
{% for key2,value in thedict.items %}
@@ -218,24 +147,43 @@
<div class="weakposcor">{{ value|floatformat:-1 }}</div>
{% elif value < -0.5 %}
<div class="negcor">{{ value|floatformat:-1 }}</div>
{% elif value < -0.1 %}
<div class="weaknegcor">{{ value|floatformat:-1 }}</div>
{% else %}
&nbsp;
{% endif %}
{% elif value < -0.1 %}
<div class="weaknegcor">{{ value|floatformat:-1 }}</div>
{% else %}
&nbsp;
{% endif %}
</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
<div class="grid_8">
</tbody>
</table>
{% endif %}
<div class="grid_8">
{{ plotdiv|safe }}
</div>
</div>
</div>
</li>
<li>
<form enctype="multipart/form-data" action="{{ formloc }}" method="post">
<table>
{{ optionsform.as_table }}
</table>
<input type="hidden" name="options" value="options">
</li>
<li>
<table>
{{ form.as_table }}
</table>
</li>
<li>
{% csrf_token %}
<input class="button green small" value="Submit" type="Submit">
</form>
</li>
</ul>
{% endblock %}
{% block sidebar %}
{% include 'menu_analytics.html' %}
{% endblock %}