Private
Public Access
1
0

thumbnails

This commit is contained in:
2024-04-07 12:11:08 +02:00
parent 560800f80c
commit bc102b2ac4
4 changed files with 28 additions and 75 deletions

View File

@@ -1994,7 +1994,7 @@ def forcecurve_multi_interactive_chart(selected): # pragma: no cover
columns = ['catch', 'slip', 'wash', 'finish', 'averageforce',
'peakforceangle', 'peakforce', 'spm', 'distance',
'workoutstate', 'driveenergy', 'cumdist']
'workoutstate', 'workoutid', 'driveenergy', 'cumdist']
rowdata = dataprep.getsmallrowdata_db(columns, ids=workoutids,
workstrokesonly=False)
@@ -2024,70 +2024,6 @@ def forcecurve_multi_interactive_chart(selected): # pragma: no cover
script, div = get_chart("/forcecurve_compare", chart_data)
return script, div
source = ColumnDataSource(
df_plot
)
TOOLS = 'save,pan,box_zoom,wheel_zoom,reset,tap,crosshair'
plot = figure(width=920,tools=TOOLS,
toolbar_location='above',
toolbar_sticky=False)
#plot.sizing_mode = 'stretch_both'
# add watermark
watermarkurl = "/static/img/logo7.png"
watermarkrange = Range1d(start=0, end=1)
watermarkalpha = 0.6
watermarkx = 0.99
watermarky = 0.01
watermarkw = 184
watermarkh = 35
watermarkanchor = 'bottom_right'
plot.extra_y_ranges = {"watermark": watermarkrange}
plot.extra_x_ranges = {"watermark": watermarkrange}
plot.image_url([watermarkurl], watermarkx, watermarky,
watermarkw, watermarkh,
global_alpha=watermarkalpha,
w_units='screen',
h_units='screen',
anchor=watermarkanchor,
dilate=True,
x_range_name="watermark",
y_range_name="watermark",
)
colors = itertools.cycle(palette)
try:
items = itertools.izip(ids, colors)
except AttributeError:
items = zip(ids, colors)
for id, color in items:
xname = 'x_'+str(id)
yname = 'y_'+str(id)
analysis = ForceCurveAnalysis.objects.get(id=id)
legendlabel = '{name}'.format(
name = analysis.name,
)
if analysis.notes:
legendlabel = '{name} - {notes}'.format(
name = analysis.name,
notes = analysis.notes
)
plot.line(xname,yname,source=source,legend_label=legendlabel,
line_width=2, color=color)
plot.legend.location = "top_left"
plot.xaxis.axis_label = "Angle"
plot.yaxis.axis_label = "Force (N)"
script, div = components(plot)
return (script, div)
def instroke_multi_interactive_chart(selected, *args, **kwargs): # pragma: no cover
df2 = []
@@ -2880,6 +2816,7 @@ def thumbnails_set(r, id, favorites):
except (KeyError, TypeError): # pragma: no cover
pass
plotnr = 1
for f in favorites:
script, div = thumbnail_flex_chart(
rowdata,
@@ -2888,7 +2825,9 @@ def thumbnails_set(r, id, favorites):
yparam1=f.yparam1,
yparam2=f.yparam2,
plottype=f.plottype,
plotnr=plotnr
)
plotnr = plotnr+1
charts.append({
'script': script,
@@ -2903,6 +2842,7 @@ def thumbnail_flex_chart(rowdata, id=0, promember=0,
yparam1='pace',
yparam2='hr',
plottype='line',
plotnr=1,
workstrokesonly=False):
try:
@@ -2938,6 +2878,25 @@ def thumbnail_flex_chart(rowdata, id=0, promember=0,
else:
rowdata['y2'] = rowdata['y1']
data_dict = rowdata.to_dict("records")
metrics_list = [{'name': name, 'rowingmetrics':d } for name, d in metrics.rowingmetrics]
chart_data = {
'title': '',
'x': xparam,
'y1': yparam1,
'y2': yparam2,
'data': data_dict,
'metrics': metrics_list,
'plottype': plottype,
'plotnr': plotnr,
}
script, div = get_chart("/miniflex", chart_data)
return script, div
if xparam == 'time':
xaxmax = tseconds.max()
xaxmin = tseconds.min()

View File

@@ -14,6 +14,7 @@
<ul class="main-content">
<canvas hidden id="canvas"></canvas>
{% if the_div %}
<li class="grid_4">
<div id="theplot" class="flexplot">

View File

@@ -3,9 +3,7 @@
<div class="mapdiv">
{{ mapdiv|safe }}
<script>
{{ mapscript|safe }}
</script>
{{ mapscript|safe }}
</div>
</li>
</ul>

View File

@@ -14,12 +14,6 @@
{{ workout.date }} - {{ workout.distance }}m - {{ workout.duration |durationprint:"%H:%M:%S.%f" }}{% endblock %}
{% block meta %}
{% leaflet_js %}
{% leaflet_css %}
<script src="https://cdn.pydata.org/bokeh/release/bokeh-3.1.1.min.js"></script>
<script async="true" type="text/javascript">
Bokeh.set_log_level("info");
</script>
{% for chart in charts %}
{{ chart.script |safe }}
@@ -51,7 +45,7 @@
"<a href=\"/rowers/workout/"+workoutid+"/flexchart?favoritechart="+counter+"\">"+element.div+"</a>"+
"</li>");
$("#id_thumbscripts").append(element.script);
$("#id_thumbs").append(element.script);
counter += 1;
});
});
@@ -64,6 +58,7 @@
{% block main %}
<script src="https://d3js.org/d3.v6.js"></script>
<p>
{% if workout|previousworkout:rower.user %}
<a href="/rowers/workout/{{ workout|previousworkout:rower.user }}/workflow"