add chart type and chart data type settings for trend analysis

This commit is contained in:
MaysWind
2024-05-26 23:58:07 +08:00
parent a9e3b79eb1
commit 5eca777891
12 changed files with 367 additions and 116 deletions
+11 -6
View File
@@ -22,13 +22,14 @@ export const useSettingsStore = defineStore('settings', {
showTotalAmountInTransactionListPage: settings.isShowTotalAmountInTransactionListPage(),
showAccountBalance: settings.isShowAccountBalance(),
statistics: {
defaultChartType: settings.getStatisticsDefaultChartType(),
defaultChartDataType: settings.getStatisticsDefaultChartDataType(),
defaultDataRangeType: settings.getStatisticsDefaultDateRange(),
defaultTimezoneType: settings.getStatisticsDefaultTimezoneType(),
defaultAccountFilter: settings.getStatisticsDefaultAccountFilter(),
defaultTransactionCategoryFilter: settings.getStatisticsDefaultTransactionCategoryFilter(),
defaultSortingType: settings.getStatisticsSortingType()
defaultSortingType: settings.getStatisticsSortingType(),
defaultCategoricalChartType: settings.getStatisticsDefaultCategoricalChartType(),
defaultTrendChartType: settings.getStatisticsDefaultTrendChartType(),
},
animate: settings.isEnableAnimate()
},
@@ -94,10 +95,6 @@ export const useSettingsStore = defineStore('settings', {
settings.setShowAccountBalance(value);
this.appSettings.showAccountBalance = value;
},
setStatisticsDefaultChartType(value) {
settings.setStatisticsDefaultChartType(value);
this.appSettings.statistics.defaultChartType = value;
},
setStatisticsDefaultChartDataType(value) {
settings.setStatisticsDefaultChartDataType(value);
this.appSettings.statistics.defaultChartDataType = value;
@@ -122,6 +119,14 @@ export const useSettingsStore = defineStore('settings', {
settings.setStatisticsSortingType(value);
this.appSettings.statistics.defaultSortingType = value;
},
setStatisticsDefaultCategoricalChartType(value) {
settings.setStatisticsDefaultCategoricalChartType(value);
this.appSettings.statistics.defaultCategoricalChartType = value;
},
setStatisticsDefaultTrendChartType(value) {
settings.setStatisticsDefaultTrendChartType(value);
this.appSettings.statistics.defaultTrendChartType = value;
},
setEnableAnimate(value) {
settings.setEnableAnimate(value);
this.appSettings.animate = value;
+36 -14
View File
@@ -28,8 +28,9 @@ export const useStatisticsStore = defineStore('statistics', {
dateType: statisticsConstants.defaultDataRangeType,
startTime: 0,
endTime: 0,
chartType: statisticsConstants.defaultCategoricalChartType,
chartDataType: statisticsConstants.defaultChartDataType,
categoricalChartType: statisticsConstants.defaultCategoricalChartType,
trendChartType: statisticsConstants.defaultTrendChartType,
filterAccountIds: {},
filterCategoryIds: {}
},
@@ -410,8 +411,9 @@ export const useStatisticsStore = defineStore('statistics', {
this.transactionStatisticsFilter.dateType = statisticsConstants.defaultDataRangeType;
this.transactionStatisticsFilter.startTime = 0;
this.transactionStatisticsFilter.endTime = 0;
this.transactionStatisticsFilter.chartType = statisticsConstants.defaultCategoricalChartType;
this.transactionStatisticsFilter.chartDataType = statisticsConstants.defaultChartDataType;
this.transactionStatisticsFilter.categoricalChartType = statisticsConstants.defaultCategoricalChartType;
this.transactionStatisticsFilter.trendChartType = statisticsConstants.defaultTrendChartType;
this.transactionStatisticsFilter.filterAccountIds = {};
this.transactionStatisticsFilter.filterCategoryIds = {};
this.transactionCategoryStatisticsData = {};
@@ -422,12 +424,6 @@ export const useStatisticsStore = defineStore('statistics', {
const settingsStore = useSettingsStore();
const userStore = useUserStore();
let defaultChartType = settingsStore.appSettings.statistics.defaultChartType;
if (defaultChartType !== statisticsConstants.allCategoricalChartTypes.Pie && defaultChartType !== statisticsConstants.allCategoricalChartTypes.Bar) {
defaultChartType = statisticsConstants.defaultCategoricalChartType;
}
let defaultChartDataType = settingsStore.appSettings.statistics.defaultChartDataType;
if (defaultChartDataType < statisticsConstants.allChartDataTypes.ExpenseByAccount.type || defaultChartDataType > statisticsConstants.allChartDataTypes.AccountTotalLiabilities.type) {
@@ -440,6 +436,18 @@ export const useStatisticsStore = defineStore('statistics', {
defaultDateRange = statisticsConstants.defaultDataRangeType;
}
let defaultCategoricalChartType = settingsStore.appSettings.statistics.defaultCategoricalChartType;
if (defaultCategoricalChartType !== statisticsConstants.allCategoricalChartTypes.Pie && defaultCategoricalChartType !== statisticsConstants.allCategoricalChartTypes.Bar) {
defaultCategoricalChartType = statisticsConstants.defaultCategoricalChartType;
}
let defaultTrendChartType = settingsStore.appSettings.statistics.defaultTrendChartType;
if (defaultTrendChartType !== statisticsConstants.allTrendChartTypes.Area && defaultTrendChartType !== statisticsConstants.allTrendChartTypes.Column) {
defaultTrendChartType = statisticsConstants.defaultTrendChartType;
}
let defaultSortType = settingsStore.appSettings.statistics.defaultSortingType;
if (defaultSortType < statisticsConstants.allSortingTypes.Amount.type || defaultSortType > statisticsConstants.allSortingTypes.Name.type) {
@@ -452,7 +460,8 @@ export const useStatisticsStore = defineStore('statistics', {
dateType: dateRange ? dateRange.dateType : undefined,
startTime: dateRange ? dateRange.minTime : undefined,
endTime: dateRange ? dateRange.maxTime : undefined,
chartType: defaultChartType,
categoricalChartType: defaultCategoricalChartType,
trendChartType: defaultTrendChartType,
chartDataType: defaultChartDataType,
filterAccountIds: settingsStore.appSettings.statistics.defaultAccountFilter || {},
filterCategoryIds: settingsStore.appSettings.statistics.defaultTransactionCategoryFilter || {},
@@ -478,10 +487,16 @@ export const useStatisticsStore = defineStore('statistics', {
this.transactionStatisticsFilter.endTime = 0;
}
if (filter && isNumber(filter.chartType)) {
this.transactionStatisticsFilter.chartType = filter.chartType;
if (filter && isNumber(filter.categoricalChartType)) {
this.transactionStatisticsFilter.categoricalChartType = filter.categoricalChartType;
} else {
this.transactionStatisticsFilter.chartType = statisticsConstants.defaultCategoricalChartType;
this.transactionStatisticsFilter.categoricalChartType = statisticsConstants.defaultCategoricalChartType;
}
if (filter && isNumber(filter.trendChartType)) {
this.transactionStatisticsFilter.trendChartType = filter.trendChartType;
} else {
this.transactionStatisticsFilter.trendChartType = statisticsConstants.defaultTrendChartType;
}
if (filter && isNumber(filter.chartDataType)) {
@@ -521,8 +536,12 @@ export const useStatisticsStore = defineStore('statistics', {
this.transactionStatisticsFilter.endTime = filter.endTime;
}
if (filter && isNumber(filter.chartType)) {
this.transactionStatisticsFilter.chartType = filter.chartType;
if (filter && isNumber(filter.categoricalChartType)) {
this.transactionStatisticsFilter.categoricalChartType = filter.categoricalChartType;
}
if (filter && isNumber(filter.trendChartType)) {
this.transactionStatisticsFilter.trendChartType = filter.trendChartType;
}
if (filter && isNumber(filter.chartDataType)) {
@@ -620,5 +639,8 @@ export const useStatisticsStore = defineStore('statistics', {
});
});
},
loadTrendAnalysis({ force }) {
return Promise.resolve(true);
},
}
});