mirror of
https://github.com/gwenhael-le-moine/ledgerrb.git
synced 2025-01-13 08:01:20 +01:00
discreteBarGraph
This commit is contained in:
parent
a2615407de
commit
c9140a6aa9
3 changed files with 114 additions and 104 deletions
File diff suppressed because one or more lines are too long
19
public/app/js/app.min.js
vendored
19
public/app/js/app.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -75,17 +75,17 @@ app.component('dashboard',
|
|||
|
||||
ctrl.filter_data = function() {
|
||||
_(ctrl.balance.buckets).each(function(bucket) {
|
||||
bucket.data = [];
|
||||
bucket.data = [{ key: 'accounts', values: [] }];
|
||||
|
||||
if (_(bucket.accounts_selected).isEmpty() && bucket.score_threshold === 0) {
|
||||
bucket.data = bucket.raw_data;
|
||||
bucket.data[0].values = bucket.raw_data;
|
||||
} else {
|
||||
_(bucket.accounts_selected).each(function(account_selected) {
|
||||
bucket.data = bucket.data.concat($filter('filter')(bucket.raw_data, account_selected, true));
|
||||
bucket.data[0].values = bucket.data[0].values.concat($filter('filter')(bucket.raw_data, account_selected, true));
|
||||
});
|
||||
}
|
||||
|
||||
bucket.total_detailed = _.chain(bucket.data)
|
||||
bucket.total_detailed = _.chain(bucket.data[0].values)
|
||||
.groupBy(function(account) {
|
||||
return account.account.split(':')[0];
|
||||
})
|
||||
|
@ -123,17 +123,22 @@ app.component('dashboard',
|
|||
}
|
||||
};
|
||||
|
||||
this.pie_graph_options = {
|
||||
this.graph_options = {
|
||||
chart: {
|
||||
type: 'pieChart',
|
||||
donut: true,
|
||||
donutRatio: 0.25,
|
||||
height: 300,
|
||||
type: 'discreteBarChart',
|
||||
height: 600,
|
||||
margin: {
|
||||
"top": 20,
|
||||
"right": 20,
|
||||
"bottom": 200,
|
||||
"left": 55
|
||||
},
|
||||
x: function(d) { return d.account; },
|
||||
y: function(d) { return d.amount; },
|
||||
showLabels: false,
|
||||
showLegend: true,
|
||||
legendPosition: 'right',
|
||||
valueFormat: function(d) { return `${d} €`; },
|
||||
showYAxis: false,
|
||||
showValues: true,
|
||||
rotateLabels: -67,
|
||||
showTooltipPercent: true,
|
||||
duration: 500,
|
||||
labelThreshold: 0.01,
|
||||
|
@ -146,10 +151,9 @@ app.component('dashboard',
|
|||
ctrl.depth = 99;
|
||||
|
||||
let retrieve_period_detailed_data = function() {
|
||||
console.log(ctrl.period)
|
||||
ctrl.balance = {
|
||||
buckets: [new Bucket('Expenses Liabilities Equity Income', ctrl.period),
|
||||
new Bucket('Assets', null)],
|
||||
buckets: [new Bucket('Expenses Liabilities Equity Income', ctrl.period)],// ,
|
||||
// new Bucket('Assets', null)],
|
||||
details: {}
|
||||
};
|
||||
|
||||
|
@ -162,7 +166,6 @@ app.component('dashboard',
|
|||
.then(function(response) {
|
||||
bucket.raw_data = _.chain(response.data)
|
||||
.map(function(account) {
|
||||
account.amount = (account.amount < 0) ? account.amount * -1 : account.amount;
|
||||
account.score = score_account(account.account);
|
||||
return account;
|
||||
})
|
||||
|
@ -233,7 +236,7 @@ app.component('dashboard',
|
|||
stacked: false,
|
||||
duration: 500,
|
||||
reduceXTicks: false,
|
||||
rotateLabels: 67,
|
||||
rotateLabels: -67,
|
||||
labelSunbeamLayout: true,
|
||||
useInteractiveGuideline: false,
|
||||
multibar: {
|
||||
|
@ -310,6 +313,7 @@ app.component('dashboard',
|
|||
<span ng:repeat="account in bucket.total_detailed">{{account.account}} = {{account.amount | number:2}} €</span>
|
||||
</md-toolbar>
|
||||
<md-content layout="row">
|
||||
<!--
|
||||
<md-card flex="20">
|
||||
<select style="height: 100%;" multiple
|
||||
ng:model="bucket.accounts_selected"
|
||||
|
@ -318,12 +322,14 @@ app.component('dashboard',
|
|||
<option value=''>...</option>
|
||||
</select>
|
||||
</md-card>
|
||||
-->
|
||||
<md-card flex="78">
|
||||
<nvd3 data="bucket.data"
|
||||
options="bucket.pie_graph_options" >
|
||||
options="bucket.graph_options" >
|
||||
</nvd3>
|
||||
</md-card>
|
||||
<!-- <md-card flex="56">
|
||||
<!--
|
||||
<md-card flex="56">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -348,7 +354,8 @@ app.component('dashboard',
|
|||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</md-card> -->
|
||||
</md-card>
|
||||
-->
|
||||
</md-content>
|
||||
</md-card>
|
||||
</md-content>
|
||||
|
|
Loading…
Reference in a new issue