fixing performance plot
This commit is contained in:
@@ -1870,6 +1870,7 @@ def performance_chart(user, startdate=None, enddate=None, kfitness=42, kfatigue=
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
plot = figure(tools=TOOLS, x_axis_type='datetime',
|
plot = figure(tools=TOOLS, x_axis_type='datetime',
|
||||||
width=900, height=300,
|
width=900, height=300,
|
||||||
toolbar_location="above",
|
toolbar_location="above",
|
||||||
@@ -1898,6 +1899,15 @@ def performance_chart(user, startdate=None, enddate=None, kfitness=42, kfatigue=
|
|||||||
y_range_name="watermark",
|
y_range_name="watermark",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
fitlabel = 'Fitness'
|
||||||
|
fatiguelabel = 'Fatigue'
|
||||||
|
formlabel = 'Freshness'
|
||||||
|
rightaxlabel = 'Freshness'
|
||||||
|
if dofatigue: # pragma: no cover
|
||||||
|
yaxlabel = 'Fitness/Fatigue'
|
||||||
|
else:
|
||||||
|
yaxlabel = 'Fitness'
|
||||||
|
|
||||||
if modelchoice == 'banister': # pragma: no cover
|
if modelchoice == 'banister': # pragma: no cover
|
||||||
fitlabel = 'PTE (fitness)'
|
fitlabel = 'PTE (fitness)'
|
||||||
fatiguelabel = 'NTE (fatigue)'
|
fatiguelabel = 'NTE (fatigue)'
|
||||||
@@ -1907,31 +1917,14 @@ def performance_chart(user, startdate=None, enddate=None, kfitness=42, kfatigue=
|
|||||||
yaxlabel = 'PTE/NTE'
|
yaxlabel = 'PTE/NTE'
|
||||||
else:
|
else:
|
||||||
yaxlabel = 'PTE'
|
yaxlabel = 'PTE'
|
||||||
else:
|
|
||||||
fitlabel = 'Fitness'
|
|
||||||
fatiguelabel = 'Fatigue'
|
|
||||||
formlabel = 'Freshness'
|
|
||||||
rightaxlabel = 'Freshness'
|
|
||||||
if dofatigue: # pragma: no cover
|
|
||||||
yaxlabel = 'Fitness/Fatigue'
|
|
||||||
else:
|
|
||||||
yaxlabel = 'Fitness'
|
|
||||||
|
|
||||||
# if showtests:
|
|
||||||
# plot.circle('date','testpower',source=source,fill_color='green',size=10,
|
|
||||||
# legend_label='Your best workouts')
|
|
||||||
|
|
||||||
plot.xaxis.axis_label = None
|
plot.xaxis.axis_label = None
|
||||||
plot.yaxis.axis_label = yaxlabel
|
plot.yaxis.axis_label = yaxlabel
|
||||||
|
|
||||||
y2rangemin = df.loc[:, ['form']].min().min()
|
y2rangemin = df.loc[:, ['form']].min().min()
|
||||||
y2rangemax = df.loc[:, ['form']].max().max()
|
y2rangemax = df.loc[:, ['form']].max().max()
|
||||||
# if dofatigue and showtests:
|
|
||||||
# y1rangemin = df.loc[:,['testpower','fitness','fatigue']].min().min()
|
|
||||||
# y1rangemax = df.loc[:,['testpower','fitness','fatigue']].max().max()*1.02
|
|
||||||
# elif showtests:
|
|
||||||
# y1rangemin = df.loc[:,['testpower','fitness']].min().min()
|
|
||||||
# y1rangemax = df.loc[:,['testpower','fitness']].max().max()*1.02
|
|
||||||
if dofatigue: # pragma: no cover
|
if dofatigue: # pragma: no cover
|
||||||
y1rangemax = df.loc[:, ['fitness', 'fatigue']].max().max()*1.02
|
y1rangemax = df.loc[:, ['fitness', 'fatigue']].max().max()*1.02
|
||||||
else:
|
else:
|
||||||
@@ -1940,7 +1933,7 @@ def performance_chart(user, startdate=None, enddate=None, kfitness=42, kfatigue=
|
|||||||
if doform: # pragma: no cover
|
if doform: # pragma: no cover
|
||||||
plot.extra_y_ranges["yax2"] = Range1d(start=y2rangemin, end=y2rangemax)
|
plot.extra_y_ranges["yax2"] = Range1d(start=y2rangemin, end=y2rangemax)
|
||||||
plot.add_layout(LinearAxis(y_range_name="yax2",
|
plot.add_layout(LinearAxis(y_range_name="yax2",
|
||||||
axis_label=rightaxlabel), "right")
|
axis_label=rightaxlabel), "right")
|
||||||
|
|
||||||
plot.line('date', 'fitness', source=source, color='blue',
|
plot.line('date', 'fitness', source=source, color='blue',
|
||||||
legend_label=fitlabel)
|
legend_label=fitlabel)
|
||||||
@@ -1957,7 +1950,7 @@ def performance_chart(user, startdate=None, enddate=None, kfitness=42, kfatigue=
|
|||||||
|
|
||||||
plot.legend.location = "top_left"
|
plot.legend.location = "top_left"
|
||||||
|
|
||||||
plot.sizing_mode = 'scale_both'
|
#plot.sizing_mode = 'scale_both'
|
||||||
|
|
||||||
startdate = datetime.datetime.combine(
|
startdate = datetime.datetime.combine(
|
||||||
startdate, datetime.datetime.min.time())
|
startdate, datetime.datetime.min.time())
|
||||||
@@ -1977,7 +1970,6 @@ def performance_chart(user, startdate=None, enddate=None, kfitness=42, kfatigue=
|
|||||||
linked_crosshair = CrosshairTool(dimensions='height')
|
linked_crosshair = CrosshairTool(dimensions='height')
|
||||||
|
|
||||||
hover.tooltips = OrderedDict([
|
hover.tooltips = OrderedDict([
|
||||||
# (legend_label,'@testpower'),
|
|
||||||
('Date', '@fdate'),
|
('Date', '@fdate'),
|
||||||
(fitlabel, '@fitness{int}'),
|
(fitlabel, '@fitness{int}'),
|
||||||
(fatiguelabel, '@fatigue{int}'),
|
(fatiguelabel, '@fatigue{int}'),
|
||||||
@@ -1987,7 +1979,6 @@ def performance_chart(user, startdate=None, enddate=None, kfitness=42, kfatigue=
|
|||||||
|
|
||||||
if showtests:
|
if showtests:
|
||||||
hover.tooltips = OrderedDict([
|
hover.tooltips = OrderedDict([
|
||||||
# (legend_label,'@testpower'),
|
|
||||||
('Date', '@fdate'),
|
('Date', '@fdate'),
|
||||||
(fitlabel, '@fitness{int}'),
|
(fitlabel, '@fitness{int}'),
|
||||||
(fatiguelabel, '@fatigue{int}'),
|
(fatiguelabel, '@fatigue{int}'),
|
||||||
@@ -2008,7 +1999,7 @@ def performance_chart(user, startdate=None, enddate=None, kfitness=42, kfatigue=
|
|||||||
plot2.vbar(x=df['date'], top=df['impulse'], color='gray')
|
plot2.vbar(x=df['date'], top=df['impulse'], color='gray')
|
||||||
plot2.vbar(x=df['date'], top=0*df['testpower']+df['impulse'], color='red')
|
plot2.vbar(x=df['date'], top=0*df['testpower']+df['impulse'], color='red')
|
||||||
|
|
||||||
plot2.sizing_mode = 'scale_both'
|
#plot2.sizing_mode = 'scale_both'
|
||||||
plot2.yaxis.axis_label = 'Impulse'
|
plot2.yaxis.axis_label = 'Impulse'
|
||||||
plot2.xaxis.axis_label = 'Date'
|
plot2.xaxis.axis_label = 'Date'
|
||||||
|
|
||||||
@@ -2016,7 +2007,6 @@ def performance_chart(user, startdate=None, enddate=None, kfitness=42, kfatigue=
|
|||||||
plot2.add_tools(linked_crosshair)
|
plot2.add_tools(linked_crosshair)
|
||||||
|
|
||||||
mylayout = layoutcolumn([plot, plot2])
|
mylayout = layoutcolumn([plot, plot2])
|
||||||
#mylayout.sizing_mode = 'stretch_both'
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
script, div = components(mylayout)
|
script, div = components(mylayout)
|
||||||
@@ -3566,7 +3556,7 @@ def interactive_otwcpchart(powerdf, promember=0, rowername="", r=None,
|
|||||||
watermarkh = 35
|
watermarkh = 35
|
||||||
watermarkanchor = 'bottom_right'
|
watermarkanchor = 'bottom_right'
|
||||||
plot.extra_y_ranges = {"watermark": watermarkrange}
|
plot.extra_y_ranges = {"watermark": watermarkrange}
|
||||||
plot.sizing_mode = 'scale_both'
|
#plot.sizing_mode = 'scale_both'
|
||||||
|
|
||||||
plot.image_url([watermarkurl], 1.8*max(thesecs), watermarky,
|
plot.image_url([watermarkurl], 1.8*max(thesecs), watermarky,
|
||||||
watermarkw, watermarkh,
|
watermarkw, watermarkh,
|
||||||
@@ -3895,7 +3885,7 @@ def interactive_cpchart(rower, thedistances, thesecs, theavpower,
|
|||||||
watermarkh = 35
|
watermarkh = 35
|
||||||
watermarkanchor = 'bottom_right'
|
watermarkanchor = 'bottom_right'
|
||||||
plot.extra_y_ranges = {"watermark": watermarkrange}
|
plot.extra_y_ranges = {"watermark": watermarkrange}
|
||||||
plot.sizing_mode = 'scale_both'
|
#plot.sizing_mode = 'scale_both'
|
||||||
|
|
||||||
plot.image_url([watermarkurl], 1.8*max(thesecs), watermarky,
|
plot.image_url([watermarkurl], 1.8*max(thesecs), watermarky,
|
||||||
watermarkw, watermarkh,
|
watermarkw, watermarkh,
|
||||||
@@ -6838,7 +6828,7 @@ def interactive_otw_advanced_pace_chart(id=0, promember=0):
|
|||||||
watermarkanchor = 'bottom_right'
|
watermarkanchor = 'bottom_right'
|
||||||
plot.extra_y_ranges = {"watermark": watermarkrange}
|
plot.extra_y_ranges = {"watermark": watermarkrange}
|
||||||
plot.extra_x_ranges = {"watermark": watermarkrange}
|
plot.extra_x_ranges = {"watermark": watermarkrange}
|
||||||
plot.sizing_mode = 'scale_both'
|
#plot.sizing_mode = 'scale_both'
|
||||||
|
|
||||||
plot.image_url([watermarkurl], watermarkx, watermarky,
|
plot.image_url([watermarkurl], watermarkx, watermarky,
|
||||||
watermarkw, watermarkh,
|
watermarkw, watermarkh,
|
||||||
|
|||||||
@@ -11,52 +11,53 @@
|
|||||||
<script>
|
<script>
|
||||||
|
|
||||||
function submit_form() {
|
function submit_form() {
|
||||||
console.log("form changed");
|
console.log("form changed");
|
||||||
var frm = $("#performanceform");
|
var frm = $("#performanceform");
|
||||||
|
|
||||||
var data = new FormData(frm[0]);
|
var data = new FormData(frm[0]);
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url:"/rowers/performancemanager/user/{{ rower.user.id }}/",
|
url:"/rowers/performancemanager/user/{{ rower.user.id }}/",
|
||||||
type: "POST",
|
type: "POST",
|
||||||
contentType: false,
|
contentType: false,
|
||||||
processData: false,
|
processData: false,
|
||||||
data: data,
|
data: data,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
|
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
console.log(data);
|
console.log(data.div);
|
||||||
// var parsedJSON = $.parseJSON(data); //
|
|
||||||
$("#id_script").replaceWith('<div id="id_script">'+data.script+'</d'+'iv>');
|
// var parsedJSON = $.parseJSON(data); //
|
||||||
$("#id_chart").replaceWith('<div id="id_chart">'+data.div+'</d'+'iv>');
|
$("#id_script").replaceWith('<div id="id_script">'+data.script+'</d'+'iv>');
|
||||||
$("#endfitness").html(data.endfitness)
|
$("#id_chart").replaceWith('<div id="id_chart">'+data.div+'</d'+'iv>');
|
||||||
$("#endfatigue").html(data.endfatigue)
|
$("#endfitness").html(data.endfitness)
|
||||||
$("#endform").html(data.endform)
|
$("#endfatigue").html(data.endfatigue)
|
||||||
console.log('done');
|
$("#endform").html(data.endform)
|
||||||
}
|
console.log('done');
|
||||||
});
|
}
|
||||||
};
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
var csrftoken = jQuery("[name=csrfmiddlewaretoken]").val();
|
var csrftoken = jQuery("[name=csrfmiddlewaretoken]").val();
|
||||||
console.log("CSRF token",csrftoken);
|
console.log("CSRF token",csrftoken);
|
||||||
|
|
||||||
function csrfSafeMethod(method) {
|
function csrfSafeMethod(method) {
|
||||||
// these HTTP methods do not require CSRF protection
|
// these HTTP methods do not require CSRF protection
|
||||||
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
|
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
|
||||||
}
|
}
|
||||||
$.ajaxSetup({
|
$.ajaxSetup({
|
||||||
beforeSend: function(xhr, settings) {
|
beforeSend: function(xhr, settings) {
|
||||||
if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
|
if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
|
||||||
xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
$("#performanceform").on('change', function(evt) {
|
||||||
|
submit_form();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
$("#performanceform").on('change', function(evt) {
|
|
||||||
submit_form();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|||||||
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
Binary file not shown.
Reference in New Issue
Block a user