-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from marosmola/finance-graph
create admin site with finance summary and graph
- Loading branch information
Showing
3 changed files
with
147 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
{% extends 'admin/change_list.html' %} | ||
{% block content_title %} | ||
<h1>Finance Summary</h1> | ||
{% endblock %} | ||
|
||
{% load humanize %} | ||
{% block result_list %} | ||
|
||
<canvas id="myChart" width="400" height="400"></canvas> | ||
<div class=”results”> | ||
<table> | ||
<thead> | ||
<tr> | ||
<th style="padding: 8px;"> | ||
<div class=”text”> | ||
Month | ||
</div> | ||
</th> | ||
<th style="padding: 8px;"> | ||
<div class=”text”> | ||
Salaries | ||
</div> | ||
</th> | ||
<th style="padding: 8px;"> | ||
<div class=”text”> | ||
Fees | ||
</div> | ||
</th> | ||
<th style="padding: 8px;"> | ||
<div class=”text”> | ||
<strong>Profit</strong> | ||
</div> | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for key, value in data.items %} | ||
<tr class="{% cycle 'row1' 'row2' %}"> | ||
<td>{{ key }}</td> | ||
<td>{{ value.salaries }}</td> | ||
<td>{{ value.fees }}</td> | ||
<td><strong>{{ value.profit }}</strong></td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
</div> | ||
|
||
<script src="https://cdn.jsdelivr.net/npm/chart.js@2.8.0"></script> | ||
<script type="text/javascript"> | ||
var ctx = document.getElementById("myChart").getContext("2d"); | ||
var data = JSON.parse("{{ graph_data | escapejs }}") | ||
|
||
var myBarChart = new Chart(ctx, { | ||
type: 'bar', | ||
data: data, | ||
options: { | ||
responsive: false, | ||
barValueSpacing: 20, | ||
scales: { | ||
yAxes: [{ | ||
ticks: { | ||
min: 0, | ||
} | ||
}] | ||
} | ||
} | ||
}); | ||
|
||
</script> | ||
{% endblock %} | ||
{% block pagination %}{% endblock %} |