mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-19 10:53:37 +00:00
Fix chart thing.
This commit is contained in:
@@ -21,13 +21,11 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
|||||||
* @property \Carbon\Carbon $created_at
|
* @property \Carbon\Carbon $created_at
|
||||||
* @property \Carbon\Carbon $updated_at
|
* @property \Carbon\Carbon $updated_at
|
||||||
* @property string $type
|
* @property string $type
|
||||||
* @property boolean $editable
|
|
||||||
* @property-read \Illuminate\Database\Eloquent\Collection|Account[] $accounts
|
* @property-read \Illuminate\Database\Eloquent\Collection|Account[] $accounts
|
||||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\AccountType whereId($value)
|
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\AccountType whereId($value)
|
||||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\AccountType whereCreatedAt($value)
|
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\AccountType whereCreatedAt($value)
|
||||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\AccountType whereUpdatedAt($value)
|
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\AccountType whereUpdatedAt($value)
|
||||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\AccountType whereType($value)
|
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\AccountType whereType($value)
|
||||||
* @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\AccountType whereEditable($value)
|
|
||||||
* @mixin \Eloquent
|
* @mixin \Eloquent
|
||||||
*/
|
*/
|
||||||
class AccountType extends Model
|
class AccountType extends Model
|
||||||
|
@@ -42,7 +42,6 @@ class AccountList implements BinderInterface
|
|||||||
|
|
||||||
/** @var \Illuminate\Support\Collection $object */
|
/** @var \Illuminate\Support\Collection $object */
|
||||||
$object = Account::leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
|
$object = Account::leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
|
||||||
->where('account_types.editable', 1)
|
|
||||||
->whereIn('accounts.id', $ids)
|
->whereIn('accounts.id', $ids)
|
||||||
->where('user_id', Auth::user()->id)
|
->where('user_id', Auth::user()->id)
|
||||||
->get(['accounts.*']);
|
->get(['accounts.*']);
|
||||||
|
@@ -1,8 +1,10 @@
|
|||||||
/* globals google, startDate ,reportURL, endDate , reportType ,accountIds , picker:true, minDate, expenseRestShow:true, incomeRestShow:true, year, month, hideTheRest, showTheRest, showTheRestExpense, hideTheRestExpense, columnChart, lineChart, stackedColumnChart */
|
/* globals google, startDate ,reportURL, endDate , reportType ,accountIds , picker:true, minDate, expenseRestShow:true, incomeRestShow:true, year, month, hideTheRest, showTheRest, showTheRestExpense, hideTheRestExpense, columnChart, lineChart, stackedColumnChart */
|
||||||
|
|
||||||
|
var chartDrawn;
|
||||||
|
var budgetChart;
|
||||||
$(function () {
|
$(function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
chartDrawn = false;
|
||||||
drawChart();
|
drawChart();
|
||||||
|
|
||||||
// click open the top X income list:
|
// click open the top X income list:
|
||||||
@@ -26,9 +28,68 @@ function clickBudgetChart(e) {
|
|||||||
"use strict";
|
"use strict";
|
||||||
var link = $(e.target);
|
var link = $(e.target);
|
||||||
var budgetId = link.data('budget');
|
var budgetId = link.data('budget');
|
||||||
console.log('Budget id is ' + budgetId);
|
var URL = 'chart/budget/period/' + budgetId + '/' + reportType + '/' + startDate + '/' + endDate + '/' + accountIds;
|
||||||
$('#budget_chart').empty();
|
var container = 'budget_chart';
|
||||||
columnChart('chart/budget/period/' + budgetId + '/' + reportType + '/' + startDate + '/' + endDate + '/' + accountIds, 'budget_chart');
|
// if chart drawn is false, draw the first one, then
|
||||||
|
// set to true
|
||||||
|
if (chartDrawn == false) {
|
||||||
|
// do new chart:
|
||||||
|
|
||||||
|
|
||||||
|
$.getJSON(URL).done(function (data) {
|
||||||
|
console.log('Will draw new columnChart(' + URL + ')');
|
||||||
|
|
||||||
|
var ctx = document.getElementById(container).getContext("2d");
|
||||||
|
var newData = {};
|
||||||
|
newData.datasets = [];
|
||||||
|
|
||||||
|
for (var i = 0; i < data.count; i++) {
|
||||||
|
newData.labels = data.labels;
|
||||||
|
var dataset = data.datasets[i];
|
||||||
|
dataset.backgroundColor = fillColors[i];
|
||||||
|
newData.datasets.push(dataset);
|
||||||
|
}
|
||||||
|
// completely new chart.
|
||||||
|
budgetChart = new Chart(ctx, {
|
||||||
|
type: 'bar',
|
||||||
|
data: data,
|
||||||
|
options: defaultColumnOptions
|
||||||
|
});
|
||||||
|
|
||||||
|
}).fail(function () {
|
||||||
|
$('#' + container).addClass('general-chart-error');
|
||||||
|
});
|
||||||
|
console.log('URL for column chart : ' + URL);
|
||||||
|
chartDrawn = true;
|
||||||
|
} else {
|
||||||
|
console.log('Will now handle remove data and add new!');
|
||||||
|
$.getJSON(URL).done(function (data) {
|
||||||
|
console.log('Will draw updated columnChart(' + URL + ')');
|
||||||
|
var newData = {};
|
||||||
|
newData.datasets = [];
|
||||||
|
|
||||||
|
for (var i = 0; i < data.count; i++) {
|
||||||
|
newData.labels = data.labels;
|
||||||
|
var dataset = data.datasets[i];
|
||||||
|
dataset.backgroundColor = fillColors[i];
|
||||||
|
newData.datasets.push(dataset);
|
||||||
|
}
|
||||||
|
// update the chart
|
||||||
|
console.log('Now update chart thing.');
|
||||||
|
budgetChart.data.datasets = newData.datasets;
|
||||||
|
budgetChart.update();
|
||||||
|
|
||||||
|
}).fail(function () {
|
||||||
|
$('#' + container).addClass('general-chart-error');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// if chart drawn is true, add new data to existing chart.
|
||||||
|
// console.log('Budget id is ' + budgetId);
|
||||||
|
// $('#budget_chart').empty();
|
||||||
|
// columnChart('chart/budget/period/' + budgetId + '/' + reportType + '/' + startDate + '/' + endDate + '/' + accountIds, 'budget_chart');
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user