forked from mirrors/bookwyrm
Updates chart markup
This commit is contained in:
parent
fa241b08e7
commit
37cd7e684c
3 changed files with 32 additions and 42 deletions
|
@ -96,22 +96,22 @@
|
|||
</form>
|
||||
|
||||
<div class="columns is-multiline">
|
||||
<div class="column">
|
||||
<div class="column is-half">
|
||||
<h3>{% trans "Total users" %}</h3>
|
||||
<div class="box">
|
||||
<canvas id="user_stats"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="column is-half">
|
||||
<h3>{% trans "Status activity" %}</h3>
|
||||
<div class="box">
|
||||
<canvas id="status_stats"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="column is-half">
|
||||
<h3>{% trans "User signup activity" %}</h3>
|
||||
<div class="box">
|
||||
<canvas id="user_stats"></canvas>
|
||||
<canvas id="register_stats"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,24 +1,19 @@
|
|||
{% load i18n %}
|
||||
<script>
|
||||
const labels = [{% for label in registration_stats.labels %}"{{ label }}",{% endfor %}];
|
||||
const data = {
|
||||
labels: labels,
|
||||
datasets: [{
|
||||
label: '{% trans "Active this month" %}',
|
||||
backgroundColor: 'rgb(75, 192, 192)',
|
||||
borderColor: 'rgb(75, 192, 192)',
|
||||
data: {{ register_stats.total }},
|
||||
}]
|
||||
};
|
||||
|
||||
const config = {
|
||||
type: 'line',
|
||||
data: data,
|
||||
options: {}
|
||||
};
|
||||
|
||||
var userStats = new Chart(
|
||||
document.getElementById('user_stats'),
|
||||
config
|
||||
var registerStats = new Chart(
|
||||
document.getElementById('register_stats'),
|
||||
{
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: [{% for label in register_stats.labels %}"{{ label }}",{% endfor %}],
|
||||
datasets: [{
|
||||
label: '{% trans "Registrations" %}',
|
||||
backgroundColor: 'rgb(75, 192, 192)',
|
||||
borderColor: 'rgb(75, 192, 192)',
|
||||
data: {{ register_stats.total }},
|
||||
}]
|
||||
},
|
||||
options: {}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
|
|
@ -1,26 +1,21 @@
|
|||
{% load i18n %}
|
||||
<script>
|
||||
const status_labels = [{% for label in status_stats.labels %}"{{ label }}",{% endfor %}];
|
||||
const status_data = {
|
||||
labels: status_labels,
|
||||
datasets: [{
|
||||
label: '{% trans "Statuses posted" %}',
|
||||
backgroundColor: 'rgb(255, 99, 132)',
|
||||
borderColor: 'rgb(255, 99, 132)',
|
||||
data: {{ status_stats.total }},
|
||||
}]
|
||||
};
|
||||
// === include 'setup' then 'config' above ===
|
||||
|
||||
const status_config = {
|
||||
type: 'bar',
|
||||
data: status_data,
|
||||
options: {}
|
||||
};
|
||||
|
||||
var statusStats = new Chart(
|
||||
document.getElementById('status_stats'),
|
||||
status_config
|
||||
{
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: [{% for label in status_stats.labels %}"{{ label }}",{% endfor %}],
|
||||
datasets: [{
|
||||
label: '{% trans "Statuses posted" %}',
|
||||
backgroundColor: 'rgb(255, 99, 132)',
|
||||
borderColor: 'rgb(255, 99, 132)',
|
||||
data: {{ status_stats.total }},
|
||||
}]
|
||||
},
|
||||
options: {}
|
||||
},
|
||||
);
|
||||
</script>
|
||||
|
||||
|
|
Loading…
Reference in a new issue