|
18 | 18 | PLOT_WIDTH = 600
|
19 | 19 |
|
20 | 20 |
|
21 |
| -def get_db_data(known_games: str) -> typing.Tuple[typing.Dict[str, int], typing.Dict[datetime.date, typing.Dict[str, int]]]: |
| 21 | +def get_db_data(known_games: typing.Set[str]) -> typing.Tuple[typing.Counter[str], |
| 22 | + typing.DefaultDict[datetime.date, typing.Dict[str, int]]]: |
22 | 23 | games_played = defaultdict(Counter)
|
23 | 24 | total_games = Counter()
|
24 | 25 | cutoff = date.today()-timedelta(days=30)
|
@@ -93,7 +94,7 @@ def stats():
|
93 | 94 | occurences, legend_label=game, line_width=2, color=game_to_color[game])
|
94 | 95 |
|
95 | 96 | total = sum(total_games.values())
|
96 |
| - pie = figure(plot_height=350, title=f"Games Played in the Last 30 Days (Total: {total})", toolbar_location=None, |
| 97 | + pie = figure(title=f"Games Played in the Last 30 Days (Total: {total})", toolbar_location=None, |
97 | 98 | tools="hover", tooltips=[("Game:", "@games"), ("Played:", "@count")],
|
98 | 99 | sizing_mode="scale_both", width=PLOT_WIDTH, height=500, x_range=(-0.5, 1.2))
|
99 | 100 | pie.axis.visible = False
|
@@ -121,7 +122,8 @@ def stats():
|
121 | 122 | start_angle="start_angles", end_angle="end_angles", fill_color="colors",
|
122 | 123 | source=ColumnDataSource(data=data), legend_field="games")
|
123 | 124 |
|
124 |
| - per_game_charts = [create_game_played_figure(games_played, game, game_to_color[game]) for game in total_games |
| 125 | + per_game_charts = [create_game_played_figure(games_played, game, game_to_color[game]) for game in |
| 126 | + sorted(total_games, key=lambda game: total_games[game]) |
125 | 127 | if total_games[game] > 1]
|
126 | 128 |
|
127 | 129 | script, charts = components((plot, pie, *per_game_charts))
|
|
0 commit comments