cleaning + tickangle

This commit is contained in:
Gwenhael Le Moine 2021-05-24 12:26:06 +02:00
parent fe4ac79498
commit 742b064145
No known key found for this signature in database
GPG key ID: FDFE3669426707A7

View file

@ -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)
}; };
} ), } ),