diff --git a/public/app/js/app.js b/public/app/js/app.js index 725c8088..fa449638 100644 --- a/public/app/js/app.js +++ b/public/app/js/app.js @@ -141,20 +141,20 @@ app.component('dashboard', { }; this.graph_options = { chart: { - type: 'discreteBarChart', + type: 'multiBarHorizontalChart', height: 600, margin: { "top": 20, "right": 20, - "bottom": 200, - "left": 55 + "bottom": 20, + "left": 200 }, x: function (d) { return d.account; }, y: function (d) { return d.amount; }, valueFormat: function (d) { return d + " \u20AC"; }, showYAxis: false, showValues: true, - rotateLabels: -67, + showLegend: false, showTooltipPercent: true, duration: 500, labelThreshold: 0.01, diff --git a/public/app/js/app.min.js b/public/app/js/app.min.js index d4ec67e8..6fc852e5 100644 --- a/public/app/js/app.min.js +++ b/public/app/js/app.min.js @@ -9,7 +9,7 @@ app.component("dashboard",{controller:["$filter","$q","API",function(a,c,d){var 2)+" "+f.currency+"\x3c/td\x3e\x3c/tr\x3e"}).join("")+"\x3ctr\x3e\x3cth\x3e\x3c/th\x3e\x3cth\x3eTotal :\x3c/th\x3e\x3cth\x3e"+c+" \u20ac\x3c/th\x3e\x3c/tr\x3e\x3c/table\x3e\x3c/md-content\x3e"}};var e=function(a){return a.match(/^Income/)?-10:a.match(/^Expenses:(courses|Hang)$/)?1:a.match(/^Expenses:Home/)?1:a.match(/^Expenses:Health/)?1:a.match(/^Expenses:Car/)?4:a.match(/^Expenses:(Food|Transport)/)?5:a.match(/^Expenses:(Shopping|Leisure)/)?9:a.match(/^Expenses:Gadgets/)?10:a.match(/^Liabilities/)? 0:a.match(/^Assets/)?-100:0};b.coloring_score=function(a){var b=a,f="#99f #0f0 #3f0 #6f0 #9f0 #cf0 #fc0 #f90 #f60 #f30 #f00".split(" ");-100>=a?(b=-1*a-100,f=["#f0f"]):-10>=a&&(b=-1*a-10,f=["#360"]);return f[b]};b.color=function(){return function(a,c){return b.coloring_score(e(a.data.account))}};b.filter_data=function(){_(b.balance.buckets).each(function(b){b.data=[{key:"accounts",values:[]}];_(b.accounts_selected).isEmpty()&&0===b.score_threshold?b.data[0].values=b.raw_data:_(b.accounts_selected).each(function(c){b.data[0].values= b.data[0].values.concat(a("filter")(b.raw_data,c,!0))});b.total_detailed=_.chain(b.data[0].values).groupBy(function(a){return a.account.split(":")[0]}).each(function(a){a.total=_(a).reduce(function(a,b){return a+b.amount},0)}).value();b.total_detailed=_.chain(b.total_detailed).keys().map(function(a){return{account:a,amount:b.total_detailed[a].total}}).value()})};var g=function(a,b){var c=this;this.categories=a;this.period=b;this.score_threshold=0;this.orderBy="amount";this.orderDesc=!1;this.order_by= -function(a){c.orderBy==a?c.orderDesc=!c.orderDesc:c.orderBy=a};this.graph_options={chart:{type:"discreteBarChart",height:600,margin:{top:20,right:20,bottom:200,left:55},x:function(a){return a.account},y:function(a){return a.amount},valueFormat:function(a){return a+" \u20ac"},showYAxis:!1,showValues:!0,rotateLabels:-67,showTooltipPercent:!0,duration:500,labelThreshold:.01,labelSunbeamLayout:!0,labelsOutside:!0}}};b.depth=99;var h=function(){b.balance={buckets:[new g("Expenses Liabilities Equity Income", +function(a){c.orderBy==a?c.orderDesc=!c.orderDesc:c.orderBy=a};this.graph_options={chart:{type:"multiBarHorizontalChart",height:600,margin:{top:20,right:20,bottom:20,left:200},x:function(a){return a.account},y:function(a){return a.amount},valueFormat:function(a){return a+" \u20ac"},showYAxis:!1,showValues:!0,showLegend:!1,showTooltipPercent:!0,duration:500,labelThreshold:.01,labelSunbeamLayout:!0,labelsOutside:!0}}};b.depth=99;var h=function(){b.balance={buckets:[new g("Expenses Liabilities Equity Income", b.period)],details:{}};return c.all(_(b.balance.buckets).map(function(a){return d.balance({period:a.period,categories:a.categories,depth:b.depth}).then(function(c){a.raw_data=_.chain(c.data).map(function(a){a.score=e(a.account);return a}).sortBy(function(a){return 1/a.amount}).sortBy(function(a){return a.account.split(":")[0]}).value().reverse();a.raw_total=_(c.data).reduce(function(a,b){return a+b.amount},0);a.accounts_selected=a.raw_data;b.filter_data()})}))},k=function(a){return c.when(d.graph_values(a).then(function(a){b.periods= [];var c=_(a.data).reduce(function(a,b){return b.length>a.length?b:a},[]);_.chain(c).pluck("date").each(function(b){_(a.data).each(function(a){var c=_(a).find({date:b});_(c).isUndefined()&&a.push({date:b,amount:0,currency:_(a).first().currency})})});_(a.data).each(function(a){a=_(a).sortBy(function(a){return a.date})});b.graphiques={monthly_values:{options:{chart:{type:"multiBarChart",height:300,showControls:!1,showLegend:!0,showLabels:!0,stacked:!1,duration:500,reduceXTicks:!1,rotateLabels:-67,labelSunbeamLayout:!0, useInteractiveGuideline:!1,multibar:{dispatch:{elementClick:function(a){b.period=a.data.x;h()}}}}},data:_.chain(a.data).keys().reverse().map(function(c){var d="Income"==c?-1:1;return{key:c,values:_.chain(a.data[c]).map(function(a){var e=new Date(a.date);e=e.getFullYear()+"-"+(9>e.getMonth()?"0":"")+(e.getMonth()+1);b.periods.push(e);return{key:c,x:e,y:parseInt(a.amount)*d}}).sortBy(function(a){return a.x}).value()}}).value()}};b.periods=_.chain(b.periods).uniq().sort().reverse().value();b.period= diff --git a/public/app/ts/components/dashboard.ts b/public/app/ts/components/dashboard.ts index 2c58f982..5e0afb98 100644 --- a/public/app/ts/components/dashboard.ts +++ b/public/app/ts/components/dashboard.ts @@ -125,20 +125,21 @@ app.component('dashboard', this.graph_options = { chart: { - type: 'discreteBarChart', + //type: 'discreteBarChart', + type: 'multiBarHorizontalChart', height: 600, margin: { "top": 20, "right": 20, - "bottom": 200, - "left": 55 + "bottom": 20, + "left": 200 }, x: function(d) { return d.account; }, y: function(d) { return d.amount; }, valueFormat: function(d) { return `${d} €`; }, showYAxis: false, showValues: true, - rotateLabels: -67, + showLegend: false, showTooltipPercent: true, duration: 500, labelThreshold: 0.01,