mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-20 17:54:30 +08:00
show no data in trend card when there are really no data in recent 6 months
This commit is contained in:
@@ -103,8 +103,8 @@
|
|||||||
</v-col>
|
</v-col>
|
||||||
|
|
||||||
<v-col cols="12" md="6">
|
<v-col cols="12" md="6">
|
||||||
<monthly-income-and-expense-card :data="monthlyIncomeAndExpenseData"
|
<monthly-income-and-expense-card :data="monthlyIncomeAndExpenseData" :is-dark-mode="isDarkMode"
|
||||||
:disabled="loadingOverview" :is-dark-mode="isDarkMode" />
|
:loading="loadingOverview" :disabled="loadingOverview" />
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
|
|
||||||
@@ -207,6 +207,10 @@ export default {
|
|||||||
const self = this;
|
const self = this;
|
||||||
const data = [];
|
const data = [];
|
||||||
|
|
||||||
|
if (!self.transactionOverview || !self.transactionOverview.thisMonth || !self.transactionOverview.thisMonth.valid) {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
[ 'monthBeforeLast4Months', 'monthBeforeLast3Months', 'monthBeforeLast2Months', 'monthBeforeLastMonth', 'lastMonth', 'thisMonth' ].forEach(fieldName => {
|
[ 'monthBeforeLast4Months', 'monthBeforeLast3Months', 'monthBeforeLast2Months', 'monthBeforeLastMonth', 'lastMonth', 'thisMonth' ].forEach(fieldName => {
|
||||||
if (!Object.prototype.hasOwnProperty.call(self.transactionOverview, fieldName)) {
|
if (!Object.prototype.hasOwnProperty.call(self.transactionOverview, fieldName)) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -4,7 +4,13 @@
|
|||||||
<span class="text-2xl font-weight-bold">{{ $t('Trend in Income and Expense') }}</span>
|
<span class="text-2xl font-weight-bold">{{ $t('Trend in Income and Expense') }}</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<v-chart class="overview-monthly-chart" autoresize :option="chartOptions" />
|
<v-card-text class="overview-monthly-chart overview-monthly-chart-no-data-tips" v-if="!loading && !hasAnyData">
|
||||||
|
<div class="d-flex flex-column align-center justify-center w-100 h-100">
|
||||||
|
<h2 style="margin-top: -40px">{{ $t('No data') }}</h2>
|
||||||
|
</div>
|
||||||
|
</v-card-text>
|
||||||
|
|
||||||
|
<v-chart autoresize class="overview-monthly-chart" :class="{ 'readonly': !hasAnyData }" :option="chartOptions"/>
|
||||||
</v-card>
|
</v-card>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -20,6 +26,7 @@ import {
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: [
|
props: [
|
||||||
|
'loading',
|
||||||
'data',
|
'data',
|
||||||
'disabled',
|
'disabled',
|
||||||
'isDarkMode'
|
'isDarkMode'
|
||||||
@@ -32,6 +39,21 @@ export default {
|
|||||||
defaultCurrency() {
|
defaultCurrency() {
|
||||||
return this.userStore.currentUserDefaultCurrency;
|
return this.userStore.currentUserDefaultCurrency;
|
||||||
},
|
},
|
||||||
|
hasAnyData() {
|
||||||
|
if (!this.data || !this.data.length || this.data.length < 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let i = 0; i < this.data.length; i++) {
|
||||||
|
const item = this.data[i];
|
||||||
|
|
||||||
|
if (item.incomeAmount > 0 || item.incomeAmount < 0 || item.expenseAmount > 0 || item.expenseAmount < 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
},
|
||||||
chartOptions() {
|
chartOptions() {
|
||||||
const self = this;
|
const self = this;
|
||||||
const monthNames = [];
|
const monthNames = [];
|
||||||
@@ -244,6 +266,11 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
.overview-monthly-chart-no-data-tips {
|
||||||
|
position: absolute !important;
|
||||||
|
z-index: 10;
|
||||||
|
}
|
||||||
|
|
||||||
.overview-monthly-chart {
|
.overview-monthly-chart {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 400px;
|
height: 400px;
|
||||||
|
|||||||
Reference in New Issue
Block a user