Skip to content

Commit

Permalink
Show team name in bubble tooltips
Browse files Browse the repository at this point in the history
  • Loading branch information
merlinorg committed Jan 19, 2025
1 parent 27a4787 commit 5b2d785
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions freezing/web/templates/explore/indiv_elev_dist.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@
}
},
point: {
r: ({index}) => jsonData.speeds[index],
r: ({index}) => jsonData.speeds[index] * jsonData.speeds[index] / 12,
},
tooltip: {
contents: function ([{index}]) {
return "<table class='" + this.CLASS.tooltip + "'>" +
"<tr><th colspan='2'>" + jsonData.labels[index] + "</th></tr>" +
"<tr><th colspan='2' style='text-align: center'>" + jsonData.athletes[index] + "<br />" + jsonData.teams[index] + "</th></tr>" +
"<tr><td class='name'>distance</td><td class='value'>" + Math.round(jsonData.distances[index]).toLocaleString() + " mi</td></tr>" +
"<tr><td class='name'>elevation</td><td class='value'>" + Math.round(jsonData.elevations[index]).toLocaleString() + " feet</td></tr>" +
"<tr><td class='name'>speed</td><td class='value'>" + +jsonData.speeds[index]?.toFixed(1) + "mph</td></tr>" +
Expand Down
2 changes: 1 addition & 1 deletion freezing/web/templates/leaderboard/team_various.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
format: {
title: (i) => '#' + jsonData.ranks[i] + ': ' + jsonData.labels[i],
value: (value, ratio, id, index) =>
jsonData.tooltips ? jsonData.tooltips[index] : +value.toFixed(jsonData.precision ?? 0) + jsonData.suffix
jsonData.tooltips ? jsonData.tooltips[index] : (+value.toFixed(jsonData.precision ?? 0)).toLocaleString() + jsonData.suffix
},
},
legend: {
Expand Down
9 changes: 6 additions & 3 deletions freezing/web/views/chartdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -863,19 +863,22 @@ def indiv_elev_dist():

indiv_q = meta.scoped_session().execute(q).fetchall() # @UndefinedVariable

labels = []
athletes = []
teams = []
elevations = []
distances = []
speeds = []
for i, res in enumerate(indiv_q):
labels.append(res["athlete_name"])
athletes.append(res["athlete_name"])
teams.append(res["team_name"])
elevations.append(int(res["total_elevation_gain"]))
distances.append(res["total_distance"])
speeds.append(res["avg_speed"])

return jsonify(
{
"labels": labels,
"athletes": athletes,
"teams": teams,
"elevations": elevations,
"distances": distances,
"speeds": speeds,
Expand Down

0 comments on commit 5b2d785

Please sign in to comment.