charts age decline of 2k power per weight/sex group
This commit is contained in:
@@ -473,6 +473,10 @@ def strfdelta(tdelta):
|
||||
|
||||
return res
|
||||
|
||||
def timedelta_to_seconds(tdelta):
|
||||
return 60.*tdelta.minute+tdelta.second
|
||||
|
||||
|
||||
# A nice printable format for pace values
|
||||
|
||||
|
||||
|
||||
@@ -1069,6 +1069,37 @@ def interactive_otwcpchart(powerdf,promember=0):
|
||||
|
||||
return [script,div,p1,ratio,message]
|
||||
|
||||
def interactive_agegroup_plot(df):
|
||||
|
||||
age = df['agemin']
|
||||
power = df['power']
|
||||
|
||||
poly_coefficients = np.polyfit(age,power,6)
|
||||
|
||||
age2 = np.linspace(11,95)
|
||||
poly_vals = np.polyval(poly_coefficients,age2)
|
||||
|
||||
source = ColumnDataSource(
|
||||
data = dict(
|
||||
age = age,
|
||||
power = power,
|
||||
age2 = age2,
|
||||
poly_vals = poly_vals
|
||||
)
|
||||
)
|
||||
|
||||
plot = Figure(plot_width=900)
|
||||
plot.circle('age','power',source=source,fill_color='red',size=15,
|
||||
legend='2k Power')
|
||||
plot.line(age2,poly_vals)
|
||||
plot.xaxis.axis_label = "Age"
|
||||
plot.yaxis.axis_label = "Concept2 2k power"
|
||||
|
||||
|
||||
script,div = components(plot)
|
||||
|
||||
return script,div
|
||||
|
||||
def interactive_cpchart(rower,thedistances,thesecs,theavpower,
|
||||
theworkouts,promember=0):
|
||||
|
||||
|
||||
47
rowers/templates/agegroupchart.html
Normal file
47
rowers/templates/agegroupchart.html
Normal file
@@ -0,0 +1,47 @@
|
||||
{% extends "base.html" %}
|
||||
{% load staticfiles %}
|
||||
{% load rowerfilters %}
|
||||
|
||||
{% block title %}Rowsandall {% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<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>
|
||||
|
||||
{{ interactiveplot |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, false, false);
|
||||
};
|
||||
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 id="workouts" class="grid_12 alpha">
|
||||
|
||||
|
||||
<h1>Interactive Plot</h1>
|
||||
|
||||
|
||||
{{ the_div|safe }}
|
||||
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
@@ -10930,6 +10930,15 @@ def agegrouprecordview(request,sex='male',weightcategory='hwt'):
|
||||
)
|
||||
)
|
||||
|
||||
df['seconds'] = df['duration'].apply(
|
||||
lambda x:dataprep.timedelta_to_seconds(x)
|
||||
)
|
||||
|
||||
script,div = interactive_agegroup_plot(df)
|
||||
|
||||
return render(request, 'agegroupchart.html',
|
||||
{
|
||||
'interactiveplot':script,
|
||||
'the_div':div,
|
||||
})
|
||||
|
||||
return HttpResponse(1)
|
||||
|
||||
Reference in New Issue
Block a user