mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-19 10:53:31 +00:00
Fix small JS bug.
This commit is contained in:
@@ -114,6 +114,9 @@ function displayAjaxPartial(data, holder) {
|
|||||||
|
|
||||||
// trigger list thing
|
// trigger list thing
|
||||||
listLengthInitial();
|
listLengthInitial();
|
||||||
|
|
||||||
|
// budget thing
|
||||||
|
$('.budget-chart-activate').unbind('click').on('click', clickBudgetChart);
|
||||||
}
|
}
|
||||||
|
|
||||||
function failAjaxPartial(uri, holder) {
|
function failAjaxPartial(uri, holder) {
|
||||||
@@ -122,3 +125,68 @@ function failAjaxPartial(uri, holder) {
|
|||||||
$('#' + holder).removeClass('loading').addClass('general-chart-error');
|
$('#' + holder).removeClass('loading').addClass('general-chart-error');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function clickBudgetChart(e) {
|
||||||
|
"use strict";
|
||||||
|
var link = $(e.target);
|
||||||
|
var budgetId = link.data('budget');
|
||||||
|
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');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
@@ -8,9 +8,6 @@ $(function () {
|
|||||||
drawChart();
|
drawChart();
|
||||||
|
|
||||||
loadAjaxPartial('budgetOverview',budgetYearOverviewUri);
|
loadAjaxPartial('budgetOverview',budgetYearOverviewUri);
|
||||||
|
|
||||||
// trigger thing for budgets:
|
|
||||||
$('.budget-chart-activate').unbind('click').on('click', clickBudgetChart);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function drawChart() {
|
function drawChart() {
|
||||||
@@ -22,68 +19,3 @@ function drawChart() {
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function clickBudgetChart(e) {
|
|
||||||
"use strict";
|
|
||||||
var link = $(e.target);
|
|
||||||
var budgetId = link.data('budget');
|
|
||||||
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');
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
Reference in New Issue
Block a user