support click in trend chart in overview page
This commit is contained in:
@@ -174,7 +174,8 @@
|
|||||||
|
|
||||||
<v-col cols="12" md="6">
|
<v-col cols="12" md="6">
|
||||||
<monthly-income-and-expense-card :data="monthlyIncomeAndExpenseData" :is-dark-mode="isDarkMode"
|
<monthly-income-and-expense-card :data="monthlyIncomeAndExpenseData" :is-dark-mode="isDarkMode"
|
||||||
:loading="loadingOverview" :disabled="loadingOverview" />
|
:loading="loadingOverview" :disabled="loadingOverview"
|
||||||
|
:enable-click-item="true" @click="clickMonthlyIncomeOrExpense" />
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
|
|
||||||
@@ -194,7 +195,11 @@ import { useAccountsStore } from '@/stores/account.js';
|
|||||||
import { useOverviewStore } from '@/stores/overview.js';
|
import { useOverviewStore } from '@/stores/overview.js';
|
||||||
|
|
||||||
import datetimeConstants from '@/consts/datetime.js';
|
import datetimeConstants from '@/consts/datetime.js';
|
||||||
import { formatUnixTime } from '@/lib/datetime.js';
|
import {
|
||||||
|
formatUnixTime,
|
||||||
|
getUnixTimeBeforeUnixTime,
|
||||||
|
getUnixTimeAfterUnixTime
|
||||||
|
} from '@/lib/datetime.js';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
mdiRefresh,
|
mdiRefresh,
|
||||||
@@ -376,6 +381,13 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
clickMonthlyIncomeOrExpense(e) {
|
||||||
|
const minTime = e.monthStartTime;
|
||||||
|
const maxTime = getUnixTimeBeforeUnixTime(getUnixTimeAfterUnixTime(minTime, 1, 'months'), 1, 'seconds');
|
||||||
|
const type = e.transactionType;
|
||||||
|
|
||||||
|
this.$router.push(`/transactions?type=${type}&dateType=${datetimeConstants.allDateRanges.Custom.type}&maxTime=${maxTime}&minTime=${minTime}`);
|
||||||
|
},
|
||||||
getDisplayCurrency(value, currencyCode) {
|
getDisplayCurrency(value, currencyCode) {
|
||||||
return this.$locale.getDisplayCurrency(value, currencyCode, {
|
return this.$locale.getDisplayCurrency(value, currencyCode, {
|
||||||
currencyDisplayMode: this.settingsStore.appSettings.currencyDisplayMode,
|
currencyDisplayMode: this.settingsStore.appSettings.currencyDisplayMode,
|
||||||
|
|||||||
@@ -19,7 +19,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
|
|
||||||
<v-chart autoresize class="overview-monthly-chart-container" :class="{ 'readonly': !hasAnyData }" :option="chartOptions"/>
|
<v-chart autoresize class="overview-monthly-chart-container"
|
||||||
|
:class="{ 'readonly': !hasAnyData }" :option="chartOptions" @click="clickItem"/>
|
||||||
</v-card>
|
</v-card>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -28,6 +29,7 @@ import { mapStores } from 'pinia';
|
|||||||
import { useSettingsStore } from '@/stores/setting.js';
|
import { useSettingsStore } from '@/stores/setting.js';
|
||||||
import { useUserStore } from '@/stores/user.js';
|
import { useUserStore } from '@/stores/user.js';
|
||||||
|
|
||||||
|
import transactionConstants from '@/consts/transaction.js';
|
||||||
import {
|
import {
|
||||||
parseDateFromUnixTime,
|
parseDateFromUnixTime,
|
||||||
getMonthName
|
getMonthName
|
||||||
@@ -38,7 +40,11 @@ export default {
|
|||||||
'loading',
|
'loading',
|
||||||
'data',
|
'data',
|
||||||
'disabled',
|
'disabled',
|
||||||
'isDarkMode'
|
'isDarkMode',
|
||||||
|
'enableClickItem'
|
||||||
|
],
|
||||||
|
emits: [
|
||||||
|
'click'
|
||||||
],
|
],
|
||||||
computed: {
|
computed: {
|
||||||
...mapStores(useSettingsStore, useUserStore),
|
...mapStores(useSettingsStore, useUserStore),
|
||||||
@@ -251,6 +257,25 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
clickItem: function (e) {
|
||||||
|
if (!this.enableClickItem || !this.data || e.componentType !== 'series') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const clickData = this.data[e.dataIndex];
|
||||||
|
|
||||||
|
if (clickData && e.seriesId === 'seriesIncome') {
|
||||||
|
this.$emit('click', {
|
||||||
|
transactionType: transactionConstants.allTransactionTypes.Income,
|
||||||
|
monthStartTime: clickData.monthStartTime
|
||||||
|
});
|
||||||
|
} else if (clickData && e.seriesId === 'seriesExpense') {
|
||||||
|
this.$emit('click', {
|
||||||
|
transactionType: transactionConstants.allTransactionTypes.Expense,
|
||||||
|
monthStartTime: clickData.monthStartTime
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
getDisplayCurrency(value, currencyCode) {
|
getDisplayCurrency(value, currencyCode) {
|
||||||
return this.$locale.getDisplayCurrency(value, currencyCode, {
|
return this.$locale.getDisplayCurrency(value, currencyCode, {
|
||||||
currencyDisplayMode: this.settingsStore.appSettings.currencyDisplayMode,
|
currencyDisplayMode: this.settingsStore.appSettings.currencyDisplayMode,
|
||||||
|
|||||||
Reference in New Issue
Block a user