mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-12 18:02:34 +00:00
Fixed the account overview chart
This commit is contained in:
@@ -360,7 +360,7 @@ class AccountController extends Controller
|
|||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
public function specificPeriod(Account $account, string $date)
|
public function period(Account $account, string $date)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$start = new Carbon($date);
|
$start = new Carbon($date);
|
||||||
|
|||||||
@@ -1,95 +0,0 @@
|
|||||||
/*
|
|
||||||
* show_with_date.js
|
|
||||||
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
|
||||||
*
|
|
||||||
* This software may be modified and distributed under the terms
|
|
||||||
* of the MIT license. See the LICENSE file for details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Return a helper with preserved width of cells
|
|
||||||
var fixHelper = function (e, tr) {
|
|
||||||
"use strict";
|
|
||||||
var $originals = tr.children();
|
|
||||||
var $helper = tr.clone();
|
|
||||||
$helper.children().each(function (index) {
|
|
||||||
// Set helper cell sizes to match the original sizes
|
|
||||||
$(this).width($originals.eq(index).width());
|
|
||||||
});
|
|
||||||
return $helper;
|
|
||||||
};
|
|
||||||
|
|
||||||
$(function () {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
lineChart(periodUri, 'period-specific-account');
|
|
||||||
|
|
||||||
pieChart(incomeCategoryUri, 'account-cat-in');
|
|
||||||
pieChart(expenseCategoryUri, 'account-cat-out');
|
|
||||||
pieChart(expenseBudgetUri, 'account-budget-out');
|
|
||||||
|
|
||||||
|
|
||||||
// sortable!
|
|
||||||
if (typeof $(".sortable-table tbody").sortable !== "undefined") {
|
|
||||||
$(".sortable-table tbody").sortable(
|
|
||||||
{
|
|
||||||
helper: fixHelper,
|
|
||||||
items: 'tr:not(.ignore)',
|
|
||||||
stop: sortStop,
|
|
||||||
handle: '.handle',
|
|
||||||
start: function (event, ui) {
|
|
||||||
// Build a placeholder cell that spans all the cells in the row
|
|
||||||
var cellCount = 0;
|
|
||||||
$('td, th', ui.helper).each(function () {
|
|
||||||
// For each TD or TH try and get it's colspan attribute, and add that or 1 to the total
|
|
||||||
var colspan = 1;
|
|
||||||
var colspanAttr = $(this).attr('colspan');
|
|
||||||
if (colspanAttr > 1) {
|
|
||||||
colspan = colspanAttr;
|
|
||||||
}
|
|
||||||
cellCount += colspan;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Add the placeholder UI - note that this is the item's content, so TD rather than TR
|
|
||||||
ui.placeholder.html('<td colspan="' + cellCount + '"> </td>');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
).disableSelection();
|
|
||||||
} else {
|
|
||||||
console.log('its null');
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
function sortStop(event, ui) {
|
|
||||||
"use strict";
|
|
||||||
var current = $(ui.item);
|
|
||||||
console.log('sort stop');
|
|
||||||
var thisDate = current.data('date');
|
|
||||||
var originalBG = current.css('backgroundColor');
|
|
||||||
|
|
||||||
|
|
||||||
if (current.prev().data('date') !== thisDate && current.next().data('date') !== thisDate) {
|
|
||||||
// animate something with color:
|
|
||||||
current.animate({backgroundColor: "#d9534f"}, 200, function () {
|
|
||||||
$(this).animate({backgroundColor: originalBG}, 200);
|
|
||||||
});
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// do update
|
|
||||||
var list = $('tr[data-date="' + thisDate + '"]');
|
|
||||||
var submit = [];
|
|
||||||
$.each(list, function (i, v) {
|
|
||||||
var row = $(v);
|
|
||||||
var id = row.data('id');
|
|
||||||
submit.push(id);
|
|
||||||
});
|
|
||||||
|
|
||||||
// do extra animation when done?
|
|
||||||
$.post('transaction/reorder', {items: submit, date: thisDate, _token: token});
|
|
||||||
|
|
||||||
current.animate({backgroundColor: "#5cb85c"}, 200, function () {
|
|
||||||
$(this).animate({backgroundColor: originalBG}, 200);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,13 @@
|
|||||||
/* global $, lineChart, accountID, token, incomeByCategoryUri, expenseByCategoryUri, expenseByBudgetUri */
|
/*
|
||||||
|
* show.js
|
||||||
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
||||||
|
*
|
||||||
|
* This software may be modified and distributed under the terms of the
|
||||||
|
* Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||||
|
*
|
||||||
|
* See the LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
// Return a helper with preserved width of cells
|
|
||||||
var fixHelper = function (e, tr) {
|
var fixHelper = function (e, tr) {
|
||||||
"use strict";
|
"use strict";
|
||||||
var $originals = tr.children();
|
var $originals = tr.children();
|
||||||
@@ -15,7 +21,7 @@ var fixHelper = function (e, tr) {
|
|||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
lineChart(singleUri, 'overview-chart');
|
lineChart(chartUri, 'overview-chart');
|
||||||
pieChart(incomeCategoryUri, 'account-cat-in');
|
pieChart(incomeCategoryUri, 'account-cat-in');
|
||||||
pieChart(expenseCategoryUri, 'account-cat-out');
|
pieChart(expenseCategoryUri, 'account-cat-out');
|
||||||
pieChart(expenseBudgetUri, 'account-budget-out');
|
pieChart(expenseBudgetUri, 'account-budget-out');
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="box-body">
|
<div class="box-body">
|
||||||
<canvas id="period-specific-account" style="width:100%;height:350px;" height="350"></canvas>
|
<canvas id="overview-chart" style="width:100%;height:350px;" height="350"></canvas>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -94,7 +94,7 @@
|
|||||||
var dateString = "{{ date|escape }}";
|
var dateString = "{{ date|escape }}";
|
||||||
|
|
||||||
// uri's for charts:
|
// uri's for charts:
|
||||||
var periodUri = '{{ route('chart.account.single', [account.id, date]) }}';
|
var chartUri = '{{ route('chart.account.period', [account.id, date]) }}';
|
||||||
var incomeCategoryUri = '{{ route('chart.account.income-category', [account.id, start.format('Ymd'), end.format('Ymd')]) }}';
|
var incomeCategoryUri = '{{ route('chart.account.income-category', [account.id, start.format('Ymd'), end.format('Ymd')]) }}';
|
||||||
var expenseCategoryUri = '{{ route('chart.account.expense-category', [account.id, start.format('Ymd'), end.format('Ymd')]) }}';
|
var expenseCategoryUri = '{{ route('chart.account.expense-category', [account.id, start.format('Ymd'), end.format('Ymd')]) }}';
|
||||||
var expenseBudgetUri = '{{ route('chart.account.expense-budget', [account.id, start.format('Ymd'), end.format('Ymd')]) }}';
|
var expenseBudgetUri = '{{ route('chart.account.expense-budget', [account.id, start.format('Ymd'), end.format('Ymd')]) }}';
|
||||||
@@ -105,6 +105,6 @@
|
|||||||
<script type="text/javascript" src="js/ff/charts.js"></script>
|
<script type="text/javascript" src="js/ff/charts.js"></script>
|
||||||
<script src="js/lib/jquery-ui.min.js" type="text/javascript"></script>
|
<script src="js/lib/jquery-ui.min.js" type="text/javascript"></script>
|
||||||
<script src="js/lib/jquery.color-2.1.2.min.js" type="text/javascript"></script>
|
<script src="js/lib/jquery.color-2.1.2.min.js" type="text/javascript"></script>
|
||||||
<script src="js/ff/accounts/show-by-date.js" type="text/javascript"></script>
|
<script src="js/ff/accounts/show.js" type="text/javascript"></script>
|
||||||
<script type="text/javascript" src="js/ff/transactions/list.js"></script>
|
<script type="text/javascript" src="js/ff/transactions/list.js"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -123,7 +123,7 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var accountID = {{ account.id }};
|
var accountID = {{ account.id }};
|
||||||
// uri's for charts:
|
// uri's for charts:
|
||||||
var singleUri = '{{ route('chart.account.single', [account.id]) }}';
|
var chartUri = '{{ route('chart.account.single', [account.id]) }}';
|
||||||
var incomeCategoryUri = '{{ route('chart.account.income-category', [account.id, start.format('Ymd'), end.format('Ymd')]) }}';
|
var incomeCategoryUri = '{{ route('chart.account.income-category', [account.id, start.format('Ymd'), end.format('Ymd')]) }}';
|
||||||
var expenseCategoryUri = '{{ route('chart.account.expense-category', [account.id, start.format('Ymd'), end.format('Ymd')]) }}';
|
var expenseCategoryUri = '{{ route('chart.account.expense-category', [account.id, start.format('Ymd'), end.format('Ymd')]) }}';
|
||||||
var expenseBudgetUri = '{{ route('chart.account.expense-budget', [account.id, start.format('Ymd'), end.format('Ymd')]) }}';
|
var expenseBudgetUri = '{{ route('chart.account.expense-budget', [account.id, start.format('Ymd'), end.format('Ymd')]) }}';
|
||||||
|
|||||||
Reference in New Issue
Block a user