(chart) add progress chart to simplify with the pie chart

This commit is contained in:
Julien Calixte
2020-04-18 12:26:53 +02:00
parent a0ce8a8aab
commit 2578aff2ae
4 changed files with 44 additions and 11 deletions

View File

@@ -0,0 +1,36 @@
<template>
<div class="chart-progress">
<div
v-for="slice in slices"
:key="slice.key"
:style="{ flex: slice.percent, backgroundColor: slice.color }"
></div>
</div>
</template>
<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator'
import ISlice from '@/models/ISlice'
@Component
export default class ChartProgress extends Vue {
@Prop({ type: Array, default: () => [] })
public slices!: ISlice[]
}
</script>
<style scoped lang="scss">
$percent-height: 1.2rem;
.chart-progress {
margin: auto;
display: flex;
flex: 1;
justify-content: center;
align-items: center;
div {
height: $percent-height;
}
}
</style>

View File

@@ -1,11 +1,6 @@
<template> <template>
<div class="tag-list no-margin"> <div class="tag-list no-margin">
<div class="columns"> <div class="columns is-vcentered">
<div class="column">
<div class="chart-container">
<chart-pie :slices="slices" />
</div>
</div>
<div class="column legend-container"> <div class="column legend-container">
<table class="table is-fullwidth"> <table class="table is-fullwidth">
<tr <tr
@@ -15,7 +10,7 @@
class="legend-item" class="legend-item"
> >
<td> <td>
<awe-icon :icon="categories[slice.key].tag.icon" /> <awe-icon :icon="categories[slice.key || ''].tag.icon" />
</td> </td>
<td class="legend-label">{{ slice.label }}</td> <td class="legend-label">{{ slice.label }}</td>
<td class="percent-label numeric"> <td class="percent-label numeric">
@@ -24,6 +19,9 @@
</tr> </tr>
</table> </table>
</div> </div>
<div class="column">
<chart-progress :slices="slices" />
</div>
</div> </div>
<div> <div>
<div class="field has-addons has-addons-centered is-narrow"> <div class="field has-addons has-addons-centered is-narrow">
@@ -101,7 +99,7 @@ interface ICategory {
@Component({ @Component({
components: { components: {
'chart-pie': () => import('@/components/ChartPie.vue'), 'chart-progress': () => import('@/components/Charts/ChartProgress.vue'),
'account-transaction-list': () => 'account-transaction-list': () =>
import('@/components/AccountTransactionList.vue') import('@/components/AccountTransactionList.vue')
} }
@@ -188,9 +186,6 @@ export default class TagList extends Vue {
position: sticky; position: sticky;
top: calc(3.25rem + 15px); top: calc(3.25rem + 15px);
} }
.chart-container {
padding: 15px;
}
.legend-container { .legend-container {
display: flex; display: flex;
table { table {

View File

@@ -11,6 +11,7 @@
@import '~bulma/sass/elements/container.sass'; @import '~bulma/sass/elements/container.sass';
@import '~bulma/sass/elements/table.sass'; @import '~bulma/sass/elements/table.sass';
@import '~bulma/sass/elements/title.sass'; @import '~bulma/sass/elements/title.sass';
@import '~bulma/sass/elements/progress.sass';
@import '~bulma/sass/elements/other.sass'; @import '~bulma/sass/elements/other.sass';
@import '~bulma/sass/form/_all.sass'; @import '~bulma/sass/form/_all.sass';
@import '~bulma/sass/layout/_all.sass'; @import '~bulma/sass/layout/_all.sass';

View File

@@ -4,5 +4,6 @@ $main: #2c3e50;
$green: hsl(141, 63%, 44%); $green: hsl(141, 63%, 44%);
$red: hsl(348, 54%, 52%); $red: hsl(348, 54%, 52%);
$white: #fff; $white: #fff;
$progress-border-radius: 0;
@import '~bulma/sass/utilities/_all.sass'; @import '~bulma/sass/utilities/_all.sass';