Display multiple charts per row, reduce overall chart size
This commit is contained in:
parent
249972c7fd
commit
66921499ad
|
@ -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;
|
||||||
|
}
|
||||||
|
|
|
@ -29,8 +29,8 @@ def get_db_data():
|
||||||
@app.route('/stats')
|
@app.route('/stats')
|
||||||
@cache.memoize(timeout=60*60) # regen once per hour should be plenty
|
@cache.memoize(timeout=60*60) # regen once per hour should be plenty
|
||||||
def stats():
|
def stats():
|
||||||
plot = figure(title="Games played per day", x_axis_type='datetime', x_axis_label="Date", y_axis_label="Played",
|
plot = figure(title="Games Played Per Day", x_axis_type='datetime', x_axis_label="Date",
|
||||||
sizing_mode="scale_both")
|
y_axis_label="Games Played", sizing_mode="scale_both", width=500, height=500)
|
||||||
|
|
||||||
total_games, games_played = get_db_data()
|
total_games, games_played = get_db_data()
|
||||||
days = sorted(games_played)
|
days = sorted(games_played)
|
||||||
|
@ -45,9 +45,9 @@ def stats():
|
||||||
occurences, legend_label=game, line_width=2, color=next(cyc_palette))
|
occurences, legend_label=game, line_width=2, color=next(cyc_palette))
|
||||||
|
|
||||||
total = sum(total_games.values())
|
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")],
|
tools="hover", tooltips=[("Game:", "@games"), ("Played:", "@count")],
|
||||||
sizing_mode="scale_both")
|
sizing_mode="scale_both", width=500, height=500)
|
||||||
pie.axis.visible = False
|
pie.axis.visible = False
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
|
@ -73,4 +73,4 @@ def stats():
|
||||||
|
|
||||||
script, charts = components((plot, pie))
|
script, charts = components((plot, pie))
|
||||||
return render_template("stats.html", js_resources=INLINE.render_js(), css_resources=INLINE.render_css(),
|
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))
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
{% extends 'pageWrapper.html' %}
|
{% extends 'pageWrapper.html' %}
|
||||||
|
|
||||||
{% block head %}
|
{% block head %}
|
||||||
<title>Statistics</title>
|
<title>Archipelago Game Statistics</title>
|
||||||
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename="styles/markdown.css") }}" />
|
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename="styles/markdown.css") }}" />
|
||||||
|
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename="styles/stats.css") }}" />
|
||||||
{{ css_resources|indent(4)|safe }}
|
{{ css_resources|indent(4)|safe }}
|
||||||
{{ js_resources|indent(4)|safe }}
|
{{ js_resources|indent(4)|safe }}
|
||||||
{{ chart_data|indent(4)|safe }}
|
{{ chart_data|indent(4)|safe }}
|
||||||
|
@ -11,11 +12,17 @@
|
||||||
{% block body %}
|
{% block body %}
|
||||||
{% include 'header/grassFlowersHeader.html' %}
|
{% include 'header/grassFlowersHeader.html' %}
|
||||||
<div id="stats" class="markdown">
|
<div id="stats" class="markdown">
|
||||||
<h1>Stats</h1>
|
<h1>Archipelago Game Statistics</h1>
|
||||||
{% for chart in charts %}
|
<h5>
|
||||||
{{ chart|indent(12)|safe }}
|
The data on this page is updated hourly.
|
||||||
|
</h5>
|
||||||
|
|
||||||
|
<div id="charts-wrapper">
|
||||||
|
{% for index in range(chart_count) %}
|
||||||
|
<div class="chart-container">
|
||||||
|
{{ charts[index]|indent(12)|safe }}
|
||||||
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in New Issue