diff --git a/WebHostLib/static/styles/stats.css b/WebHostLib/static/styles/stats.css new file mode 100644 index 00000000..9eb165ab --- /dev/null +++ b/WebHostLib/static/styles/stats.css @@ -0,0 +1,15 @@ +#charts-wrapper{ + display: flex; + flex-direction: row; + flex-wrap: wrap; + justify-content: space-between; +} + +.chart-container{ + display: flex; + flex-direction: column; + width: calc(50% - 15px); + min-width: 400px; + margin-bottom: 30px; +} + diff --git a/WebHostLib/stats.py b/WebHostLib/stats.py index 76f3b430..30272cdc 100644 --- a/WebHostLib/stats.py +++ b/WebHostLib/stats.py @@ -29,8 +29,8 @@ def get_db_data(): @app.route('/stats') @cache.memoize(timeout=60*60) # regen once per hour should be plenty def stats(): - plot = figure(title="Games played per day", x_axis_type='datetime', x_axis_label="Date", y_axis_label="Played", - sizing_mode="scale_both") + plot = figure(title="Games Played Per Day", x_axis_type='datetime', x_axis_label="Date", + y_axis_label="Games Played", sizing_mode="scale_both", width=500, height=500) total_games, games_played = get_db_data() days = sorted(games_played) @@ -45,9 +45,9 @@ def stats(): occurences, legend_label=game, line_width=2, color=next(cyc_palette)) total = sum(total_games.values()) - pie = figure(plot_height=350, title=f"Games played in the last 30 days. (Total: {total})", toolbar_location=None, + pie = figure(plot_height=350, title=f"Games Played in the Last 30 Days (Total: {total})", toolbar_location=None, tools="hover", tooltips=[("Game:", "@games"), ("Played:", "@count")], - sizing_mode="scale_both") + sizing_mode="scale_both", width=500, height=500) pie.axis.visible = False data = { @@ -73,4 +73,4 @@ def stats(): script, charts = components((plot, pie)) return render_template("stats.html", js_resources=INLINE.render_js(), css_resources=INLINE.render_css(), - chart_data=script, charts=charts) + chart_data=script, charts=charts, chart_count=len(charts)) diff --git a/WebHostLib/templates/stats.html b/WebHostLib/templates/stats.html index 1278a5e5..5d282907 100644 --- a/WebHostLib/templates/stats.html +++ b/WebHostLib/templates/stats.html @@ -1,8 +1,9 @@ {% extends 'pageWrapper.html' %} {% block head %} - Statistics + Archipelago Game Statistics + {{ css_resources|indent(4)|safe }} {{ js_resources|indent(4)|safe }} {{ chart_data|indent(4)|safe }} @@ -11,11 +12,17 @@ {% block body %} {% include 'header/grassFlowersHeader.html' %}
-

Stats

- {% for chart in charts %} - {{ chart|indent(12)|safe }} +

Archipelago Game Statistics

+
+ The data on this page is updated hourly. +
+ +
+ {% for index in range(chart_count) %} +
+ {{ charts[index]|indent(12)|safe }} +
{% endfor %} - - +
{% endblock %}