itneractive plot v1
This commit is contained in:
@@ -2089,10 +2089,6 @@ def course_map(course):
|
|||||||
return script, div
|
return script, div
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def leaflet_chart(lat, lon, name="", raceresult=0):
|
def leaflet_chart(lat, lon, name="", raceresult=0):
|
||||||
try:
|
try:
|
||||||
if lat.empty or lon.empty: # pragma: no cover
|
if lat.empty or lon.empty: # pragma: no cover
|
||||||
@@ -3558,110 +3554,23 @@ def interactive_chart(id=0, promember=0, intervaldata={}):
|
|||||||
except KeyError: # pragma: no cover
|
except KeyError: # pragma: no cover
|
||||||
datadf['pace'] = 0
|
datadf['pace'] = 0
|
||||||
|
|
||||||
source = ColumnDataSource(
|
data_dict = datadf.to_dict("records")
|
||||||
datadf
|
|
||||||
)
|
|
||||||
|
|
||||||
plot = figure(x_axis_type="datetime", y_axis_type="datetime",
|
metrics_list = [{'name': name, 'rowingmetrics':d } for name, d in metrics.rowingmetrics]
|
||||||
width=400,
|
|
||||||
height=400,
|
chart_data = {
|
||||||
toolbar_sticky=False,
|
'title': row.name,
|
||||||
tools=TOOLS)
|
'x': "time",
|
||||||
|
'y1': "pace",
|
||||||
|
'y2': "spm",
|
||||||
|
'data': data_dict,
|
||||||
|
'metrics': metrics_list,
|
||||||
|
}
|
||||||
|
|
||||||
# add watermark
|
script, div = get_chart("/interactive", chart_data)
|
||||||
watermarkurl = "/static/img/logo7.png"
|
|
||||||
watermarkrange = Range1d(start=0, end=1)
|
|
||||||
watermarkalpha = 0.6
|
|
||||||
watermarkw = 184
|
|
||||||
watermarkh = 35
|
|
||||||
plot.extra_y_ranges = {"watermark": watermarkrange}
|
|
||||||
plot.extra_x_ranges = {"watermark": watermarkrange}
|
|
||||||
|
|
||||||
plot.image_url([watermarkurl], 0.01, 0.99,
|
return script, div
|
||||||
0.5*watermarkw, 0.5*watermarkh,
|
|
||||||
global_alpha=watermarkalpha,
|
|
||||||
w_units='screen',
|
|
||||||
h_units='screen',
|
|
||||||
anchor='top_left',
|
|
||||||
dilate=True,
|
|
||||||
x_range_name="watermark",
|
|
||||||
y_range_name="watermark",
|
|
||||||
)
|
|
||||||
|
|
||||||
plot.line('time', 'pace', source=source, legend_label="Pace", name="pace")
|
|
||||||
|
|
||||||
try:
|
|
||||||
plot.title.text = row.name
|
|
||||||
except ValueError: # pragma: no cover
|
|
||||||
plot.title.text = ""
|
|
||||||
plot.title.text_font_size = "1.0em"
|
|
||||||
#plot.sizing_mode = 'stretch_both'
|
|
||||||
plot.xaxis.axis_label = "Time"
|
|
||||||
plot.yaxis.axis_label = "Pace (/500m)"
|
|
||||||
plot.xaxis[0].formatter = DatetimeTickFormatter(
|
|
||||||
hours=["%H"],
|
|
||||||
minutes=["%M"],
|
|
||||||
seconds=["%S"],
|
|
||||||
days=["0"],
|
|
||||||
months=[""],
|
|
||||||
years=[""]
|
|
||||||
)
|
|
||||||
plot.yaxis[0].formatter = DatetimeTickFormatter(
|
|
||||||
seconds=["%S"],
|
|
||||||
minutes=["%M"]
|
|
||||||
)
|
|
||||||
ymax = 90.
|
|
||||||
ymin = 150.
|
|
||||||
|
|
||||||
if row.workouttype == 'water':
|
|
||||||
ymax = 90.
|
|
||||||
ymin = 210.
|
|
||||||
|
|
||||||
plot.y_range = Range1d(1.e3*ymin, 1.e3*ymax)
|
|
||||||
|
|
||||||
plot.extra_y_ranges["spmax"] = Range1d(start=10, end=45)
|
|
||||||
plot.line('time', 'spm', source=source, color="red",
|
|
||||||
y_range_name="spmax", legend_label="Stroke Rate", name="spm")
|
|
||||||
plot.add_layout(LinearAxis(y_range_name="spmax",
|
|
||||||
axis_label="SPM"), 'right')
|
|
||||||
|
|
||||||
plot.legend.location = "bottom_right"
|
|
||||||
|
|
||||||
# add shaded bar chart areas
|
|
||||||
if intervaldata != {}:
|
|
||||||
intervaldf = pd.DataFrame(intervaldata)
|
|
||||||
intervaldf['itime'] = intervaldf['itime']*1.e3
|
|
||||||
intervaldf['time'] = intervaldf['itime'].cumsum()
|
|
||||||
intervaldf['time'] = intervaldf['time'].shift(1)
|
|
||||||
intervaldf.loc[0, 'time'] = 0
|
|
||||||
intervaldf['time_r'] = intervaldf['time'] + intervaldf['itime']
|
|
||||||
intervaldf['value'] = 100
|
|
||||||
mask = intervaldf['itype'] == 3
|
|
||||||
intervaldf.loc[mask, 'value'] = 0
|
|
||||||
intervaldf['bottom'] = 10
|
|
||||||
|
|
||||||
intervalsource = ColumnDataSource(
|
|
||||||
intervaldf
|
|
||||||
)
|
|
||||||
|
|
||||||
plot.quad(left='time', top='value', bottom='bottom',
|
|
||||||
right='time_r', source=intervalsource, color='mediumvioletred',
|
|
||||||
y_range_name='spmax', fill_alpha=0.2, line_alpha=0.2)
|
|
||||||
|
|
||||||
hover = plot.select(dict(type=HoverTool))
|
|
||||||
|
|
||||||
hover.tooltips = OrderedDict([
|
|
||||||
('Time', '@ftime'),
|
|
||||||
('Pace', '@fpace'),
|
|
||||||
('HR', '@hr{int}'),
|
|
||||||
('SPM', '@spm{1.1}'),
|
|
||||||
])
|
|
||||||
|
|
||||||
hover.mode = 'mouse'
|
|
||||||
# hover.name = ["spm", "pace"]
|
|
||||||
script, div = components(plot)
|
|
||||||
|
|
||||||
return [script, div]
|
|
||||||
|
|
||||||
|
|
||||||
def interactive_chart_video(videodata):
|
def interactive_chart_video(videodata):
|
||||||
@@ -3948,12 +3857,12 @@ def interactive_flexchart_stacked(id, r, xparam='time',
|
|||||||
|
|
||||||
|
|
||||||
if rowdata.empty:
|
if rowdata.empty:
|
||||||
return "", "No valid data", '', '', comment
|
return "", "No valid data"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
tseconds = rowdata.loc[:, 'time']
|
tseconds = rowdata.loc[:, 'time']
|
||||||
except KeyError: # pragma: no cover
|
except KeyError: # pragma: no cover
|
||||||
return '', 'No time data - cannot make flex plot', '', '', comment
|
return '', 'No time data - cannot make flex plot'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
rowdata['x1'] = rowdata.loc[:, xparam]
|
rowdata['x1'] = rowdata.loc[:, xparam]
|
||||||
|
|||||||
@@ -122,9 +122,6 @@ $( function() {
|
|||||||
<div id="id_script">
|
<div id="id_script">
|
||||||
{{ the_script |safe }}
|
{{ the_script |safe }}
|
||||||
</div>
|
</div>
|
||||||
<div id="ds">
|
|
||||||
{{ ds |safe }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h1>In Stroke Metrics</h1>
|
<h1>In Stroke Metrics</h1>
|
||||||
<ul class="main-content">
|
<ul class="main-content">
|
||||||
@@ -172,10 +169,16 @@ $( function() {
|
|||||||
{{ the_div|safe }}
|
{{ the_div|safe }}
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li class="grid_4">
|
<li class="grid_2">
|
||||||
<div id="dd" class="flexplot">
|
<div id="dd" class="flexplot">
|
||||||
|
<script src="https://d3js.org/d3.v6.js"></script>
|
||||||
{{ dd|safe }}
|
{{ dd|safe }}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
<div id="ds">
|
||||||
|
{{ ds |safe }}
|
||||||
|
</div>
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|||||||
@@ -104,59 +104,53 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% for course in courses %}
|
{% for course in courses %}
|
||||||
<tr>
|
<tr>
|
||||||
<th>
|
<th>
|
||||||
Timed Course:
|
Timed Course:
|
||||||
</th>
|
</th>
|
||||||
<td>
|
<td>
|
||||||
<a href="/rowers/courses/{{ course.id }}"/>{{ course }}</a>
|
<a href="/rowers/courses/{{ course.id }}"/>{{ course }}</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
</li>
|
</li>
|
||||||
<li class="grid_2">
|
<li class="grid_2">
|
||||||
<h1>Workout Summary</h1>
|
<h1>Workout Summary</h1>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<pre>
|
<pre>
|
||||||
{{ summary }}
|
{{ summary }}
|
||||||
</pre>
|
</pre>
|
||||||
</p>
|
</p>
|
||||||
</li>
|
</li>
|
||||||
{% if mapdiv %}
|
{% if mapdiv %}
|
||||||
<li class="grid_2">
|
<li class="grid_2">
|
||||||
<div class="mapdiv">
|
<div class="mapdiv">
|
||||||
|
|
||||||
{{ mapdiv|safe }}
|
{{ mapdiv|safe }}
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
{{ mapscript|safe }}
|
{{ mapscript|safe }}
|
||||||
</script>
|
</script>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<li class="grid_2">
|
<li class="grid_2">
|
||||||
<script src="https://cdn.pydata.org/bokeh/release/bokeh-3.1.1.min.js"></script>
|
<script src="https://d3js.org/d3.v6.js"></script>
|
||||||
<script async="true" type="text/javascript">
|
{{ the_div|safe }}
|
||||||
Bokeh.set_log_level("info");
|
{{ interactiveplot |safe }}
|
||||||
</script>
|
</li>
|
||||||
|
{% for graph in graphs %}
|
||||||
{{ interactiveplot |safe }}
|
<li>
|
||||||
|
<a href="/rowers/graph/{{ graph.id }}/">
|
||||||
{{ the_div|safe }}
|
|
||||||
|
|
||||||
</li>
|
|
||||||
{% for graph in graphs %}
|
|
||||||
<li>
|
|
||||||
<a href="/rowers/graph/{{ graph.id }}/">
|
|
||||||
<img src="/{{ graph.filename }}"
|
<img src="/{{ graph.filename }}"
|
||||||
onerror="this.src='/static/img/rowingtimer.gif'"
|
onerror="this.src='/static/img/rowingtimer.gif'"
|
||||||
alt="{{ graph.filename }}" width="120" height="100">
|
alt="{{ graph.filename }}" width="120" height="100">
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
{% 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