mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-12 01:42:32 +00:00
Account chart can do live update
This commit is contained in:
@@ -53,6 +53,11 @@ export default () => ({
|
||||
eventListeners: {
|
||||
['@convert-to-native.window'](event){
|
||||
console.log('I heard that! it is now ' + event.detail);
|
||||
this.convertToNative = event.detail;
|
||||
this.accountList = [];
|
||||
chartData = null;
|
||||
this.loadChart();
|
||||
this.loadAccounts();
|
||||
}
|
||||
},
|
||||
|
||||
@@ -61,6 +66,7 @@ export default () => ({
|
||||
console.log('doSomeReload');
|
||||
},
|
||||
getFreshData() {
|
||||
console.log('get fresh data');
|
||||
const start = new Date(window.store.get('start'));
|
||||
const end = new Date(window.store.get('end'));
|
||||
const chartCacheKey = getCacheKey(this.localCacheKey('chart'), {start: start, end: end})
|
||||
@@ -101,18 +107,20 @@ export default () => ({
|
||||
dataset.label = current.label;
|
||||
|
||||
// use the "native" currency code and use the "native_entries" as array
|
||||
// if (this.convertToNative) {
|
||||
// currencies.push(current.native_currency_code);
|
||||
// dataset.currency_code = current.native_currency_code;
|
||||
// collection = Object.values(current.native_entries);
|
||||
// yAxis = 'y' + current.native_currency_code;
|
||||
// }
|
||||
// if (!this.convertToNative) {
|
||||
if (this.convertToNative) {
|
||||
console.log('Convert to native!');
|
||||
currencies.push(current.native_currency_code);
|
||||
dataset.currency_code = current.native_currency_code;
|
||||
collection = Object.values(current.native_entries);
|
||||
yAxis = 'y' + current.native_currency_code;
|
||||
}
|
||||
if (!this.convertToNative) {
|
||||
console.log('NO convert to native!', this.convertToNative);
|
||||
yAxis = 'y' + current.currency_code;
|
||||
dataset.currency_code = current.currency_code;
|
||||
currencies.push(current.currency_code);
|
||||
collection = Object.values(current.entries);
|
||||
// }
|
||||
}
|
||||
dataset.yAxisID = yAxis;
|
||||
dataset.data = collection;
|
||||
|
||||
@@ -147,7 +155,9 @@ export default () => ({
|
||||
return options;
|
||||
},
|
||||
loadChart() {
|
||||
console.log('loadChart');
|
||||
if (true === this.loading) {
|
||||
console.log('already loading chart');
|
||||
return;
|
||||
}
|
||||
this.loading = true;
|
||||
@@ -165,6 +175,7 @@ export default () => ({
|
||||
chart.options = options.options;
|
||||
chart.data = options.data;
|
||||
chart.update();
|
||||
console.log('refresh chart');
|
||||
return;
|
||||
}
|
||||
chart = new Chart(document.querySelector("#account-chart"), options);
|
||||
@@ -294,6 +305,7 @@ export default () => ({
|
||||
this.convertToNative = values[1] && values[3];
|
||||
this.convertToNativeAvailable = values[3];
|
||||
afterPromises = true;
|
||||
console.log('convertToNative in accounts.js: ', values);
|
||||
|
||||
// main dashboard chart:
|
||||
this.loadChart();
|
||||
|
||||
Reference in New Issue
Block a user