removing redundant code
This commit is contained in:
@@ -1686,84 +1686,6 @@ def goldmedalscorechart(user, startdate=None, enddate=None):
|
||||
script, div = get_chart("/markerworkouts", chart_data)
|
||||
return script, div, outids
|
||||
|
||||
TOOLS = 'save,pan,box_zoom,wheel_zoom,reset,tap,hover,crosshair'
|
||||
source = ColumnDataSource(
|
||||
data=dict(
|
||||
markerscore=df['markerscore'],
|
||||
score=df['score'],
|
||||
markerduration=df['markerduration'].apply(
|
||||
lambda x: totaltime_sec_to_string(x, shorten=True)),
|
||||
duration=df['duration'].apply(
|
||||
lambda x: totaltime_sec_to_string(x, shorten=True)),
|
||||
date=df['date'],
|
||||
fdate=df['date'].map(lambda x: x.strftime('%d-%m-%Y')),
|
||||
url=df['url'],
|
||||
workout=df['workout']
|
||||
)
|
||||
)
|
||||
|
||||
plot = figure(tools=TOOLS, x_axis_type='datetime',
|
||||
width=900, height=600,
|
||||
toolbar_location='above',
|
||||
toolbar_sticky=False)
|
||||
|
||||
# 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",
|
||||
)
|
||||
|
||||
plot.xaxis.axis_label = 'Date'
|
||||
plot.yaxis.axis_label = 'Gold Medal Score'
|
||||
|
||||
plot.circle('date', 'score', source=source, fill_color='blue',
|
||||
size=10,
|
||||
legend_label='Workouts')
|
||||
|
||||
plot.circle('date', 'markerscore', source=source, fill_color='red',
|
||||
size=10,
|
||||
legend_label='Marker Workouts')
|
||||
|
||||
plot.legend.location = "bottom_left"
|
||||
|
||||
plot.x_range = Range1d(
|
||||
startdate, enddate+datetime.timedelta(days=5),
|
||||
)
|
||||
|
||||
hover = plot.select(dict(type=HoverTool))
|
||||
|
||||
hover.tooltips = OrderedDict([
|
||||
('Marker', '@markerscore{int}'),
|
||||
('Test', '@markerduration'),
|
||||
('Score', '@score{int}'),
|
||||
('Duration', '@duration'),
|
||||
('Date', '@fdate'),
|
||||
('Workout', '@workout')
|
||||
])
|
||||
|
||||
taptool = plot.select(type=TapTool)
|
||||
taptool.callback = OpenURL(url='@url')
|
||||
|
||||
script, div = components(plot)
|
||||
|
||||
return script, div, outids
|
||||
|
||||
|
||||
def performance_chart(user, startdate=None, enddate=None, kfitness=42, kfatigue=7,
|
||||
|
||||
@@ -60,14 +60,6 @@
|
||||
{% block main %}
|
||||
|
||||
|
||||
<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>
|
||||
|
||||
|
||||
|
||||
|
||||
{% if rower.user %}
|
||||
<h1>Gold Medal Scores for {{ rower.user.first_name }} </h1>
|
||||
{% else %}
|
||||
@@ -76,6 +68,7 @@
|
||||
|
||||
|
||||
<ul class="main-content">
|
||||
<canvas hidden id="canvas"></canvas>
|
||||
<li class="grid_4">
|
||||
<p>Hover over the workout to see details, click on the workout to open in a
|
||||
separate page.</p>
|
||||
|
||||
Reference in New Issue
Block a user