mirror of
https://github.com/gwenhael-le-moine/credger.git
synced 2024-12-26 09:58:36 +01:00
cleaning + tickangle
This commit is contained in:
parent
fe4ac79498
commit
742b064145
1 changed files with 6 additions and 14 deletions
|
@ -23,14 +23,6 @@
|
||||||
accounts: () => API.fetch( "/api/ledger/accounts" )
|
accounts: () => API.fetch( "/api/ledger/accounts" )
|
||||||
}
|
}
|
||||||
|
|
||||||
const Utils = {
|
|
||||||
readable_date: date => {
|
|
||||||
const months = { 0: 'Janvier', 1: 'Février', 2: 'Mars', 3: 'Avril', 4: 'Mai', 5: 'Juin', 6: 'Juillet', 7: 'Août', 8: 'Septembre', 9: 'Octobre', 10: 'Novembre', 11: 'Décembre' };
|
|
||||||
|
|
||||||
return `${months[ date.getMonth() ]} ${date.getFullYear()}`;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const Controls = {
|
const Controls = {
|
||||||
accounts_list: {
|
accounts_list: {
|
||||||
init: async ( ui_id ) => {
|
init: async ( ui_id ) => {
|
||||||
|
@ -73,7 +65,7 @@
|
||||||
let onchange = () => {
|
let onchange = () => {
|
||||||
selected_accounts = Object.keys( accounts_depths )
|
selected_accounts = Object.keys( accounts_depths )
|
||||||
.filter( act => accounts_depths[act] > 0 )
|
.filter( act => accounts_depths[act] > 0 )
|
||||||
.map( act => accounts.filter( a => a[0] == act && a.length == accounts_depths[act] ) )
|
.map( act => accounts.filter( a => a[0] == act && a.length <= accounts_depths[act] ) )
|
||||||
.flat();
|
.flat();
|
||||||
|
|
||||||
Controls.main_graph.set( selected_accounts );
|
Controls.main_graph.set( selected_accounts );
|
||||||
|
@ -89,7 +81,7 @@
|
||||||
|
|
||||||
accounts_depths[ act[0] ] = val;
|
accounts_depths[ act[0] ] = val;
|
||||||
|
|
||||||
return `<div style="float: left; width: 100%;"><label for="myRange-${act[0]}" style="float: left;"">${act}</label><input style="float: right;" type="range" min="0" max="${max_depth}" value="${val}" class="slider" name="myRange-${act[0]}" id="myRange-${act[0]}"></div>`;
|
return `<div style="float: left; width: 100%;"><label for="myRange-${act[0]}" style="float: left;">${act}</label><input style="float: right;" type="range" min="0" max="${max_depth}" value="${val}" ${val == 0 ? 'disabled' : ''} class="slider" name="myRange-${act[0]}" id="myRange-${act[0]}"></div>`;
|
||||||
}).join('');
|
}).join('');
|
||||||
|
|
||||||
Object.keys( accounts_depths ).forEach( act => {
|
Object.keys( accounts_depths ).forEach( act => {
|
||||||
|
@ -108,14 +100,14 @@
|
||||||
main_graph: {
|
main_graph: {
|
||||||
init: ( ui_id ) => {
|
init: ( ui_id ) => {
|
||||||
let layout = {
|
let layout = {
|
||||||
xaxis: {title: 'Dates'},
|
xaxis: { title: 'Dates',
|
||||||
|
tickangle: -45 },
|
||||||
yaxis: {title: 'Montant'},
|
yaxis: {title: 'Montant'},
|
||||||
barmode: 'relative',
|
barmode: 'relative',
|
||||||
title: 'Relative Barmode'
|
title: '€'
|
||||||
};
|
};
|
||||||
|
|
||||||
Controls.main_graph.set = async ( accounts ) => {
|
Controls.main_graph.set = async ( accounts ) => {
|
||||||
console.log(accounts)
|
|
||||||
if (accounts.length < 1)
|
if (accounts.length < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -128,7 +120,7 @@
|
||||||
return {
|
return {
|
||||||
name: act,
|
name: act,
|
||||||
type: "bar",
|
type: "bar",
|
||||||
x: v.map( reg => new Date( reg.date ) ), //Utils.readable_date( new Date( reg.date ) ) ),
|
x: v.map( reg => new Date( reg.date ) ),
|
||||||
y: v.map( reg => reg.amount)
|
y: v.map( reg => reg.amount)
|
||||||
};
|
};
|
||||||
} ),
|
} ),
|
||||||
|
|
Loading…
Reference in a new issue