mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 14:13:21 +00:00
Add some graphics for subscriptions stats
This commit is contained in:
parent
88762c492f
commit
22945483d6
16
core/static/core/js/Chart.bundle.min.js
vendored
Normal file
16
core/static/core/js/Chart.bundle.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -4,6 +4,11 @@
|
|||||||
{% trans %}Subscription stats{% endtrans %}
|
{% trans %}Subscription stats{% endtrans %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block head %}
|
||||||
|
{{ super() }}
|
||||||
|
<script type="text/javascript" src="{{ static('core/js/Chart.bundle.min.js') }}"></script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -14,11 +19,13 @@
|
|||||||
<p><input type="submit" value="{% trans %}Go{% endtrans %}" /></p>
|
<p><input type="submit" value="{% trans %}Go{% endtrans %}" /></p>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<canvas id="statsChart" width="400" height="200"></canvas>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
{% trans %}Total subscriptions{% endtrans %} : {{ subscriptions_total.count() }}<br><br>
|
{% trans %}Total subscriptions{% endtrans %} : {{ subscriptions_total.count() }}<br><br>
|
||||||
{% trans %}Subscriptions by type{% endtrans %}<br><br>
|
{% trans %}Subscriptions by type{% endtrans %}<br><br>
|
||||||
{% for location in locations %}
|
{% for location in locations %}
|
||||||
{{ location[1] }} : {{ subscriptions_total.filter(location=location[0]).count() }}<br>
|
{{ location[1] }} : <i class="nb">{{ subscriptions_total.filter(location=location[0]).count() }}</i><br>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<p>
|
<p>
|
||||||
|
|
||||||
@ -33,20 +40,71 @@
|
|||||||
<th>{% trans %}Total{% endtrans %}</th>
|
<th>{% trans %}Total{% endtrans %}</th>
|
||||||
{% for type in subscriptions_types %}
|
{% for type in subscriptions_types %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ subscriptions_types[type]['name'] }}</td>
|
<td><i class="types" >{{ subscriptions_types[type]['name'] }}</i></td>
|
||||||
{% set subscriptions_total_type = subscriptions_total.filter(subscription_type=type) %}
|
{% set subscriptions_total_type = subscriptions_total.filter(subscription_type=type) %}
|
||||||
{% for location in locations %}
|
{% for location in locations %}
|
||||||
<td>
|
<td>
|
||||||
{% set subscriptions_total_type_location = subscriptions_total_type.filter(location=location[0]) %}
|
{% set subscriptions_total_type_location = subscriptions_total_type.filter(location=location[0]) %}
|
||||||
{% trans %}Total{% endtrans %} : {{ subscriptions_total_type_location.count()}}<br>
|
{% trans %}Total{% endtrans %} : {{ subscriptions_total_type_location.count()}}<br>
|
||||||
{% for p_type in payment_types %}
|
{% for p_type in payment_types %}
|
||||||
{{ p_type[1] }} : {{ subscriptions_total_type_location.filter(payment_method=p_type[0]).count()}}<br>
|
{{ p_type[1] }} : <i class="nb">{{ subscriptions_total_type_location.filter(payment_method=p_type[0]).count()}}</i><br>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</td>
|
</td>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<td>{{subscriptions_total_type.count()}}
|
<td class="total"><i class="nb">{{subscriptions_total_type.count()}}</i>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block script %}
|
||||||
|
{{ super() }}
|
||||||
|
<script>
|
||||||
|
var ctx = document.getElementById("statsChart").getContext('2d');
|
||||||
|
var labels = [];
|
||||||
|
var total = [];
|
||||||
|
Array.from(document.getElementsByClassName("types")).forEach(function(element){
|
||||||
|
labels.push(element.childNodes[0].data);
|
||||||
|
});
|
||||||
|
Array.from(document.getElementsByClassName("total")).forEach(function(element){
|
||||||
|
total.push(element.childNodes[0].childNodes[0].data);
|
||||||
|
});
|
||||||
|
var myChart = new Chart(ctx, {
|
||||||
|
type: 'bar',
|
||||||
|
data: {
|
||||||
|
labels: labels,
|
||||||
|
datasets: [{
|
||||||
|
label: 'Nombre de cotisations',
|
||||||
|
data: total,
|
||||||
|
backgroundColor: [
|
||||||
|
'rgba(255, 99, 132, 0.2)',
|
||||||
|
'rgba(54, 162, 235, 0.2)',
|
||||||
|
'rgba(255, 206, 86, 0.2)',
|
||||||
|
'rgba(75, 192, 192, 0.2)',
|
||||||
|
'rgba(153, 102, 255, 0.2)',
|
||||||
|
'rgba(255, 159, 64, 0.2)'
|
||||||
|
],
|
||||||
|
borderColor: [
|
||||||
|
'rgba(255,99,132,1)',
|
||||||
|
'rgba(54, 162, 235, 1)',
|
||||||
|
'rgba(255, 206, 86, 1)',
|
||||||
|
'rgba(75, 192, 192, 1)',
|
||||||
|
'rgba(153, 102, 255, 1)',
|
||||||
|
'rgba(255, 159, 64, 1)'
|
||||||
|
],
|
||||||
|
borderWidth: 1
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
options: {
|
||||||
|
scales: {
|
||||||
|
yAxes: [{
|
||||||
|
ticks: {
|
||||||
|
beginAtZero:true
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
Loading…
Reference in New Issue
Block a user