2018-12-02 15:43:23 +00:00
|
|
|
<template>
|
|
|
|
<div class="container">
|
2018-12-03 10:53:01 +00:00
|
|
|
<pie :chart-data="chartdata" :options="options" v-if="spendings[0] !== 0"></pie>
|
2018-12-02 15:43:23 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import pie from './charjs_donut'
|
2018-12-03 10:53:01 +00:00
|
|
|
import { mapGetters } from 'vuex'
|
|
|
|
import { total } from '../libs/data_processing'
|
2018-12-02 15:43:23 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'postesComparison',
|
|
|
|
components: {
|
|
|
|
'pie': pie
|
|
|
|
},
|
|
|
|
data () {
|
|
|
|
return {
|
2018-12-03 10:53:01 +00:00
|
|
|
selected_tags: [
|
|
|
|
'virements',
|
|
|
|
'cash',
|
|
|
|
'autoroute',
|
2019-01-21 11:10:22 +00:00
|
|
|
'train',
|
2018-12-03 10:53:01 +00:00
|
|
|
'essence',
|
|
|
|
'courses',
|
|
|
|
'sans tags'
|
|
|
|
],
|
2018-12-02 15:43:23 +00:00
|
|
|
options: {
|
|
|
|
responsive: true,
|
2018-12-04 17:57:21 +00:00
|
|
|
maintainAspectRatio: false,
|
|
|
|
legend: {
|
|
|
|
position: 'left'
|
|
|
|
}
|
2018-12-02 15:43:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
2018-12-03 10:53:01 +00:00
|
|
|
...mapGetters('datas', [
|
|
|
|
'tag_filter_rows'
|
|
|
|
]),
|
2018-12-04 17:57:21 +00:00
|
|
|
...mapGetters('config', [
|
|
|
|
'tag'
|
|
|
|
]),
|
2018-12-03 10:53:01 +00:00
|
|
|
chartdata () {
|
|
|
|
return {
|
|
|
|
labels: this.selected_tags,
|
|
|
|
datasets: [
|
|
|
|
{
|
2018-12-03 11:09:28 +00:00
|
|
|
label: 'Dépenses',
|
2018-12-04 17:57:21 +00:00
|
|
|
data: this.spendings,
|
|
|
|
backgroundColor: this.selected_tags.map(t => {
|
|
|
|
if (this.tag(t)) {
|
|
|
|
return this.tag(t).color
|
|
|
|
} else {
|
|
|
|
return '#A9A9A9'
|
|
|
|
}
|
|
|
|
})
|
2018-12-03 10:53:01 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
spendings () {
|
|
|
|
var tagsSpendings = this.selected_tags.map(tag => {
|
|
|
|
if (tag) {
|
|
|
|
return total(this.tag_filter_rows([tag]))
|
|
|
|
} else {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
})
|
|
|
|
tagsSpendings[tagsSpendings.length - 1] = total(this.tag_filter_rows([])) - tagsSpendings.reduce((sum, a) => sum + a, 0)
|
|
|
|
return tagsSpendings
|
|
|
|
}
|
2018-12-02 15:43:23 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scope>
|
|
|
|
.container {
|
|
|
|
position: relative;
|
2018-12-04 17:37:28 +00:00
|
|
|
height: 420px;
|
2018-12-02 15:43:23 +00:00
|
|
|
}
|
|
|
|
</style>
|