mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-24 15:26:33 -06:00
Fix chart thing.
This commit is contained in:
parent
18d2741814
commit
b947ff50ed
@ -21,13 +21,11 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $type
|
||||
* @property boolean $editable
|
||||
* @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 whereCreatedAt($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 whereEditable($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class AccountType extends Model
|
||||
|
@ -42,7 +42,6 @@ class AccountList implements BinderInterface
|
||||
|
||||
/** @var \Illuminate\Support\Collection $object */
|
||||
$object = Account::leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
|
||||
->where('account_types.editable', 1)
|
||||
->whereIn('accounts.id', $ids)
|
||||
->where('user_id', Auth::user()->id)
|
||||
->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 */
|
||||
|
||||
|
||||
var chartDrawn;
|
||||
var budgetChart;
|
||||
$(function () {
|
||||
"use strict";
|
||||
chartDrawn = false;
|
||||
drawChart();
|
||||
|
||||
// click open the top X income list:
|
||||
@ -26,9 +28,68 @@ function clickBudgetChart(e) {
|
||||
"use strict";
|
||||
var link = $(e.target);
|
||||
var budgetId = link.data('budget');
|
||||
console.log('Budget id is ' + budgetId);
|
||||
$('#budget_chart').empty();
|
||||
columnChart('chart/budget/period/' + budgetId + '/' + reportType + '/' + startDate + '/' + endDate + '/' + accountIds, 'budget_chart');
|
||||
var URL = 'chart/budget/period/' + budgetId + '/' + reportType + '/' + startDate + '/' + endDate + '/' + accountIds;
|
||||
var container = '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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user