done comparison chart
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
from rowers.models import Workout, User, Rower, WorkoutForm,RowerForm,GraphImage
|
from rowers.models import Workout, User, Rower, WorkoutForm,RowerForm,GraphImage
|
||||||
from rowingdata import rower as rrower
|
from rowingdata import rower as rrower
|
||||||
from rowingdata import main as rmain
|
from rowingdata import main as rmain
|
||||||
@@ -1822,11 +1821,14 @@ def interactive_comparison_chart(id1=0,id2=0,xparam='distance',yparam='spm',
|
|||||||
else:
|
else:
|
||||||
rowdata2.sort_values(by='time',ascending=True,inplace=True)
|
rowdata2.sort_values(by='time',ascending=True,inplace=True)
|
||||||
|
|
||||||
x1 = rowdata1.ix[:,xparam]
|
try:
|
||||||
x2 = rowdata2.ix[:,xparam]
|
x1 = rowdata1.ix[:,xparam]
|
||||||
|
x2 = rowdata2.ix[:,xparam]
|
||||||
|
|
||||||
y1 = rowdata1.ix[:,yparam]
|
y1 = rowdata1.ix[:,yparam]
|
||||||
y2 = rowdata2.ix[:,yparam]
|
y2 = rowdata2.ix[:,yparam]
|
||||||
|
except KeyError:
|
||||||
|
return "","No valid Data Available"
|
||||||
|
|
||||||
x_axis_type = 'linear'
|
x_axis_type = 'linear'
|
||||||
y_axis_type = 'linear'
|
y_axis_type = 'linear'
|
||||||
@@ -1949,7 +1951,7 @@ def interactive_comparison_chart(id1=0,id2=0,xparam='distance',yparam='spm',
|
|||||||
plot.title.text = row1.name+' vs '+row2.name
|
plot.title.text = row1.name+' vs '+row2.name
|
||||||
plot.title.text_font_size=value("1.2em")
|
plot.title.text_font_size=value("1.2em")
|
||||||
plot.xaxis.axis_label = axlabels[xparam]
|
plot.xaxis.axis_label = axlabels[xparam]
|
||||||
|
plot.yaxis.axis_label = axlabels[yparam]
|
||||||
|
|
||||||
if xparam == 'time':
|
if xparam == 'time':
|
||||||
plot.xaxis[0].formatter = DatetimeTickFormatter(
|
plot.xaxis[0].formatter = DatetimeTickFormatter(
|
||||||
|
|||||||
@@ -6,144 +6,134 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<script type="text/javascript" src="/static/js/bokeh-0.12.3.min.js"></script>
|
<script type="text/javascript" src="/static/js/bokeh-0.12.3.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");
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{{ interactiveplot |safe }}
|
{{ interactiveplot |safe }}
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// Set things up to resize the plot on a window resize. You can play with
|
// 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.
|
// the arguments of resize_width_height() to change the plot's behavior.
|
||||||
var plot_resize_setup = function () {
|
var plot_resize_setup = function () {
|
||||||
var plotid = Object.keys(Bokeh.index)[0]; // assume we have just one plot
|
var plotid = Object.keys(Bokeh.index)[0]; // assume we have just one plot
|
||||||
var plot = Bokeh.index[plotid];
|
var plot = Bokeh.index[plotid];
|
||||||
var plotresizer = function() {
|
var plotresizer = function() {
|
||||||
// arguments: use width, use height, maintain aspect ratio
|
// arguments: use width, use height, maintain aspect ratio
|
||||||
plot.resize_width_height(true, true, false);
|
plot.resize_width_height(true, true, false);
|
||||||
};
|
};
|
||||||
window.addEventListener('resize', plotresizer);
|
window.addEventListener('resize', plotresizer);
|
||||||
plotresizer();
|
plotresizer();
|
||||||
};
|
};
|
||||||
window.addEventListener('load', plot_resize_setup);
|
window.addEventListener('load', plot_resize_setup);
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
/* Need this to get the page in "desktop mode"; not having an infinite height.*/
|
/* Need this to get the page in "desktop mode"; not having an infinite height.*/
|
||||||
html, body {height: 100%; margin:5px;}
|
html, body {height: 100%; margin:5px;}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<div id="navigation" class="grid_12 alpha">
|
<div id="navigation" class="grid_12 alpha">
|
||||||
{% if user.is_authenticated and mayedit %}
|
{% if user.is_authenticated and mayedit %}
|
||||||
<div class="grid_2 alpha">
|
<div class="grid_2 alpha">
|
||||||
<p>
|
<p>
|
||||||
<a class="button gray small" href="/rowers/workout/{{ id }}/edit">Edit Workout</a>
|
<a class="button gray small" href="/rowers/workout/{{ id }}/edit">Edit Workout</a>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid_2 suffix_8 omega">
|
<div class="grid_2 suffix_8 omega">
|
||||||
<p>
|
<p>
|
||||||
<a class="button gray small" href="/rowers/workout/compare/{{ id }}/advanced">Advanced Edit</a>
|
<a class="button gray small" href="/rowers/workout/compare/{{ id }}/advanced">Advanced Edit</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div id="other" class="grid_12 alpha">
|
<div id="other" class="grid_12 alpha">
|
||||||
<div class="grid_2 alpha">
|
<div class="grid_2 alpha">
|
||||||
<a class="button blue small"
|
<a class="button blue small"
|
||||||
href="/rowers/workout/compare/{{ id2 }}/{{ id1 }}/{{ xparam }}/{{ yparam }}/{{ plottype }}">Swap Workouts</a>
|
href="/rowers/workout/compare/{{ id2 }}/{{ id1 }}/{{ xparam }}/{{ yparam }}/{{ plottype }}">Swap Workouts</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid_2">
|
<div class="grid_2">
|
||||||
<a class="button blue small"
|
<a class="button blue small"
|
||||||
href="/rowers/workout/{{ id1 }}/edit">Edit Workout</a>
|
href="/rowers/workout/{{ id1 }}/edit">Edit Workout</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid_2 suffix_6 omega">
|
<div class="grid_2 suffix_6 omega">
|
||||||
<a class="button blue small"
|
<a class="button blue small"
|
||||||
href="/rowers/workout/{{ id1 }}/advanced">Advanced Edit</a>
|
href="/rowers/workout/{{ id1 }}/advanced">Advanced Edit</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p> </p>
|
<p> </p>
|
||||||
|
|
||||||
<div id="plotbuttons" class="grid_12 alpha">
|
<div id="plotbuttons" class="grid_12 alpha">
|
||||||
|
<div id="x-axis" class="grid_6 alpha">
|
||||||
|
<div class="grid_2 alpha dropdown">
|
||||||
|
<button class="grid_2 alpha button blue small dropbtn">X-axis</button>
|
||||||
|
<div class="dropdown-content">
|
||||||
|
{% for key, value in axchoicesbasic.items %}
|
||||||
|
{% if key != 'None' %}
|
||||||
|
<a class="button blue small alpha" href="/rowers/workout/compare/{{ id1}}/{{ id2 }}/{{ key }}/{{ yparam }}/{{ plottype }}">{{ value }}</a>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
{% if promember %}
|
||||||
|
{% for key, value in axchoicespro.items %}
|
||||||
|
<a class="button blue small alpha" href="/rowers/workout/compare/{{ id1 }}/{{ id2 }}/{{ key }}/{{ yparam }}/{{ plottype }}">{{ value }}</a>
|
||||||
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
{% for key, value in axchoicespro.items %}
|
||||||
|
<a class="button rosy small" href="/rowers/promembership">{{ value }}</a>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div id="x-axis" class="grid_6 alpha">
|
<div class="grid_2 suffix_2 omega dropdown">
|
||||||
<div class="grid_2 alpha dropdown">
|
<button class="grid_2 alpha button blue small dropbtn">Y-axis</button>
|
||||||
<button class="grid_2 alpha button blue small dropbtn">X-axis</button>
|
<div class="dropdown-content">
|
||||||
<div class="dropdown-content">
|
{% for key, value in axchoicesbasic.items %}
|
||||||
<a class="button blue small alpha" href="/rowers/workout/compare/{{ id1 }}/{{ id2 }}/time/{{ yparam }}/{{ plottype }}">Time</a>
|
{% if key not in noylist and key != 'None' %}
|
||||||
<a class="button blue small alpha" href="/rowers/workout/compare/{{ id1 }}/{{ id2 }}/distance/{{ yparam }}/{{ plottype }}">Distance</a>
|
<a class="button blue small" href="/rowers/workout/compare/{{ id1 }}/{{ id2 }}/{{ xparam }}/{{ key }}/{{ plottype }}">{{ value }}</a>
|
||||||
{% if promember %}
|
{% endif %}
|
||||||
<a class="button blue small alpha" href="/rowers/workout/compare/{{ id1 }}/{{ id2 }}/power/{{ yparam }}/scatter">Power</a>
|
{% endfor %}
|
||||||
<a class="button blue small alpha" href="/rowers/workout/compare/{{ id1 }}/{{ id2 }}/hr/{{ yparam }}/scatter">HR</a>
|
{% if promember %}
|
||||||
<a class="button blue small alpha" href="/rowers/workout/compare/{{ id1 }}/{{ id2 }}/spm/{{ yparam }}/scatter">SPM</a>
|
{% for key, value in axchoicespro.items %}
|
||||||
<a class="button blue small alpha" href="/rowers/workout/compare/{{ id1 }}/{{ id2 }}/peakforce/{{ yparam }}/scatter">Peak Force</a>
|
{% if key not in noylist %}
|
||||||
<a class="button blue small alpha" href="/rowers/workout/compare/{{ id1 }}/{{ id2 }}/averageforce/{{ yparam }}/scatter">Average Force</a>
|
<a class="button blue small" href="/rowers/workout/compare/{{ id1 }}/{{ id2 }}/{{ xparam }}/{{ key }}/{{ plottype }}">{{ value }}</a>
|
||||||
<a class="button blue small alpha" href="/rowers/workout/compare/{{ id1 }}/{{ id2 }}/forceratio/{{ yparam }}/scatter">Average/Peak Force Ratio</a>
|
{% endif %}
|
||||||
<a class="button blue small alpha" href="/rowers/workout/compare/{{ id1 }}/{{ id2 }}/drivelength/{{ yparam }}/scatter">Drive Length</a>
|
{% endfor %}
|
||||||
<a class="button blue small alpha" href="/rowers/workout/compare/{{ id1 }}/{{ id2 }}/driveenergy/{{ yparam }}/scatter">Work per Stroke</a>
|
{% else %}
|
||||||
<a class="button blue small alpha" href="/rowers/workout/compare/{{ id1 }}/{{ id2 }}/drivespeed/{{ yparam }}/scatter">Drive Speed</a>
|
{% for key, value in axchoicespro.items %}
|
||||||
{% else %}
|
{% if key not in noylist %}
|
||||||
<a class="button rosy small" href="/rowers/promembership">Power (Pro)</a>
|
<a class="button rosy small" href="/rowers/promembership">{{ value }} (Pro)</a>
|
||||||
<a class="button rosy small" href="/rowers/promembership">HR (Pro)</a>
|
{% endif %}
|
||||||
<a class="button rosy small" href="/rowers/promembership">SPM (Pro)</a>
|
{% endfor %}
|
||||||
<a class="button rosy small" href="/rowers/promembership">Peak Force (Pro)</a>
|
{% endif %}
|
||||||
<a class="button rosy small" href="/rowers/promembership">Average Force (Pro)</a>
|
|
||||||
<a class="button rosy small" href="/rowers/promembership">Average/Peak Force Ratio (Pro)</a>
|
|
||||||
<a class="button rosy small" href="/rowers/promembership">Drive Length (Pro)</a>
|
|
||||||
<a class="button rosy small" href="/rowers/promembership">Work per Stroke (Pro)</a>
|
|
||||||
<a class="button rosy small" href="/rowers/promembership">Drive Speed (Pro)</a>
|
|
||||||
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="grid_2 suffix_2 omega dropdown">
|
|
||||||
<button class="grid_2 alpha button blue small dropbtn">Y-axis</button>
|
|
||||||
<div class="dropdown-content">
|
|
||||||
<a class="button blue small" href="/rowers/workout/compare/{{ id1 }}/{{ id2 }}/{{ xparam }}/pace/{{ plottype }}">Pace</a>
|
|
||||||
<a class="button blue small" href="/rowers/workout/compare/{{ id1 }}/{{ id2 }}/{{ xparam }}/hr/{{ plottype }}">HR</a>
|
|
||||||
<a class="button blue small" href="/rowers/workout/compare/{{ id1 }}/{{ id2 }}/{{ xparam }}/spm/{{ plottype }}">SPM</a>
|
|
||||||
<a class="button blue small" href="/rowers/workout/compare/{{ id1 }}/{{ id2 }}/{{ xparam }}/power/{{ plottype }}">Power</a>
|
|
||||||
{% if promember %}
|
|
||||||
<a class="button blue small" href="/rowers/workout/compare/{{ id1 }}/{{ id2 }}/{{ xparam }}/peakforce/{{ plottype }}">Peak Force</a>
|
|
||||||
<a class="button blue small" href="/rowers/workout/compare/{{ id1 }}/{{ id2 }}/{{ xparam }}/averageforce/{{ plottype }}">Average Force</a>
|
|
||||||
<a class="button blue small" href="/rowers/workout/compare/{{ id1 }}/{{ id2 }}/{{ xparam }}/forceratio/{{ plottype }}">Average/Peak Force Ratio</a>
|
|
||||||
<a class="button blue small" href="/rowers/workout/compare/{{ id1 }}/{{ id2 }}/{{ xparam }}/drivelength/{{ plottype }}">Drive Length</a>
|
|
||||||
<a class="button blue small" href="/rowers/workout/compare/{{ id1 }}/{{ id2 }}/{{ xparam }}/driveenergy/{{ plottype }}">Work per Stroke</a>
|
|
||||||
<a class="button blue small" href="/rowers/workout/compare/{{ id1 }}/{{ id2 }}/{{ xparam }}/drivespeed/{{ plottype }}">Drive Speed</a>
|
|
||||||
{% else %}
|
|
||||||
<a class="button rosy small" href="/rowers/promembership">Peak Force (Pro)</a>
|
|
||||||
<a class="button rosy small" href="/rowers/promembership">Average Force (Pro)</a>
|
|
||||||
<a class="button rosy small" href="/rowers/promembership">Average/Peak Force Ratio (Pro)</a>
|
|
||||||
<a class="button rosy small" href="/rowers/promembership">Drive Length (Pro)</a>
|
|
||||||
<a class="button rosy small" href="/rowers/promembership">Work per Stroke (Pro)</a>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="y-axis" class="grid_6 omega">
|
|
||||||
<div class="grid_2 prefix_2 alpha">
|
</div>
|
||||||
<a class="button blue small" href="/rowers/workout/compare/{{ id1 }}/{{ id2 }}/{{ xparam }}/{{ yparam }}/line">Line Plot</a>
|
|
||||||
</div>
|
<div id="y-axis" class="grid_6 omega">
|
||||||
<div class="grid_2 omega">
|
<div class="grid_2 prefix_2 alpha">
|
||||||
<a class="button blue small" href="/rowers/workout/compare/{{ id1 }}/{{ id2 }}/{{ xparam }}/{{ yparam }}/scatter">Scatter Plot</a>
|
<a class="button blue small" href="/rowers/workout/compare/{{ id1 }}/{{ id2 }}/{{ xparam }}/{{ yparam }}/line">Line Plot</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="grid_2 omega">
|
||||||
|
<a class="button blue small" href="/rowers/workout/compare/{{ id1 }}/{{ id2 }}/{{ xparam }}/{{ yparam }}/scatter">Scatter Plot</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="theplot" class="grid_12 alpha flexplot">
|
<div id="theplot" class="grid_12 alpha flexplot">
|
||||||
|
|
||||||
|
|
||||||
{{ the_div|safe }}
|
{{ the_div|safe }}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -3253,6 +3253,10 @@ def workout_comparison_view(request,id1=0,id2=0,xparam='distance',yparam='spm'):
|
|||||||
promember=promember)
|
promember=promember)
|
||||||
script = res[0]
|
script = res[0]
|
||||||
div = res[1]
|
div = res[1]
|
||||||
|
|
||||||
|
axchoicesbasic = {ax[0]:ax[1] for ax in axes if ax[4]=='basic'}
|
||||||
|
axchoicespro = {ax[0]:ax[1] for ax in axes if ax[4]=='pro'}
|
||||||
|
noylist = ["time","distance"]
|
||||||
axchoicesbasic.pop("cumdist")
|
axchoicesbasic.pop("cumdist")
|
||||||
|
|
||||||
return render(request,
|
return render(request,
|
||||||
@@ -3260,6 +3264,9 @@ def workout_comparison_view(request,id1=0,id2=0,xparam='distance',yparam='spm'):
|
|||||||
{'interactiveplot':script,
|
{'interactiveplot':script,
|
||||||
'the_div':div,
|
'the_div':div,
|
||||||
'id1':id1,
|
'id1':id1,
|
||||||
|
'id2':id2,
|
||||||
|
'axchoicesbasic':axchoicesbasic,
|
||||||
|
'axchoicespro':axchoicespro,
|
||||||
'noylist':noylist,
|
'noylist':noylist,
|
||||||
'xparam':xparam,
|
'xparam':xparam,
|
||||||
'yparam':yparam,
|
'yparam':yparam,
|
||||||
@@ -3283,12 +3290,33 @@ def workout_comparison_view2(request,id1=0,id2=0,xparam='distance',
|
|||||||
promember=promember,plottype=plottype)
|
promember=promember,plottype=plottype)
|
||||||
script = res[0]
|
script = res[0]
|
||||||
div = res[1]
|
div = res[1]
|
||||||
|
|
||||||
|
axchoicesbasic = {ax[0]:ax[1] for ax in axes if ax[4]=='basic'}
|
||||||
|
axchoicespro = {ax[0]:ax[1] for ax in axes if ax[4]=='pro'}
|
||||||
|
noylist = ["time","distance"]
|
||||||
|
axchoicesbasic.pop("cumdist")
|
||||||
|
|
||||||
|
row1 = Workout.objects.get(id=id1)
|
||||||
|
row2 = Workout.objects.get(id=id2)
|
||||||
|
|
||||||
|
if row1.workouttype != 'water' or row2.workouttype != 'water':
|
||||||
|
axchoicespro.pop('slip')
|
||||||
|
axchoicespro.pop('wash')
|
||||||
|
axchoicespro.pop('catch')
|
||||||
|
axchoicespro.pop('finish')
|
||||||
|
axchoicespro.pop('totalangle')
|
||||||
|
axchoicespro.pop('effectiveangle')
|
||||||
|
axchoicespro.pop('peakforceangle')
|
||||||
|
|
||||||
|
|
||||||
return render(request,
|
return render(request,
|
||||||
'comparisonchart2.html',
|
'comparisonchart2.html',
|
||||||
{'interactiveplot':script,
|
{'interactiveplot':script,
|
||||||
'the_div':div,
|
'the_div':div,
|
||||||
'id1':id1,
|
'id1':id1,
|
||||||
|
'id2':id2,
|
||||||
|
'axchoicesbasic':axchoicesbasic,
|
||||||
|
'axchoicespro':axchoicespro,
|
||||||
'noylist':noylist,
|
'noylist':noylist,
|
||||||
'xparam':xparam,
|
'xparam':xparam,
|
||||||
'yparam':yparam,
|
'yparam':yparam,
|
||||||
|
|||||||
Reference in New Issue
Block a user