code refactor

This commit is contained in:
MaysWind
2023-07-09 20:43:08 +08:00
parent 522ed94c32
commit dc127ea6a3
4 changed files with 28 additions and 17 deletions
+2 -14
View File
@@ -81,21 +81,9 @@ import { mapStores } from 'pinia';
import { useSettingsStore } from '@/stores/setting.js';
import colorConstants from '@/consts/color.js';
import statisticsConstants from '@/consts/statistics.js';
import { formatPercent } from '@/lib/common.js';
const defaultColors = [
'cc4a66',
'e3564a',
'fc892c',
'ffc349',
'4dd291',
'24ceb3',
'2ab4d0',
'065786',
'713670',
'8e1d51'
];
export default {
props: [
'skeleton',
@@ -153,7 +141,7 @@ export default {
percent: (item[this.percentField] > 0 || item[this.percentField] === 0 || item[this.percentField] === '0') ? item[this.percentField] : (item[this.valueField] / totalValidValue * 100),
actualPercent: item[this.valueField] / totalValidValue,
currency: item[this.currencyField],
color: item[this.colorField] ? item[this.colorField] : defaultColors[validItems.length % defaultColors.length],
color: item[this.colorField] ? item[this.colorField] : statisticsConstants.defaultChartColors[validItems.length % statisticsConstants.defaultChartColors.length],
sourceItem: item
};
+20 -3
View File
@@ -47,20 +47,36 @@ const defaultChartDataType = allChartDataTypes.ExpenseByPrimaryCategory.type;
const allSortingTypes = {
Amount: {
type: 0,
name: 'Amount'
name: 'Amount',
fullName: 'Sort by Amount'
},
DisplayOrder: {
type: 1,
name: 'Display Order'
name: 'Display Order',
fullName: 'Sort by Display Order'
},
Name: {
type: 2,
name: 'Name'
name: 'Name',
fullName: 'Sort by Name'
}
};
const defaultSortingType = allSortingTypes.Amount.type;
const defaultChartColors = [
'cc4a66',
'e3564a',
'fc892c',
'ffc349',
'4dd291',
'24ceb3',
'2ab4d0',
'065786',
'713670',
'8e1d51'
];
export default {
allChartTypes: allChartTypes,
defaultChartType: defaultChartType,
@@ -69,4 +85,5 @@ export default {
defaultDataRangeType: datetime.allDateRanges.ThisMonth.type,
allSortingTypes: allSortingTypes,
defaultSortingType: defaultSortingType,
defaultChartColors: defaultChartColors,
};
+3
View File
@@ -975,6 +975,9 @@ export default {
'Amount': 'Amount',
'Display Order': 'Display Order',
'Name': 'Name',
'Sort by Amount': 'Sort by Amount',
'Sort by Display Order': 'Sort by Display Order',
'Sort by Name': 'Sort by Name',
'Filter Accounts': 'Filter Accounts',
'Filter Transaction Categories': 'Filter Transaction Categories',
'User Settings': 'User Settings',
+3
View File
@@ -975,6 +975,9 @@ export default {
'Amount': '金额',
'Display Order': '显示顺序',
'Name': '名称',
'Sort by Amount': '按金额排序',
'Sort by Display Order': '按显示顺序排序',
'Sort by Name': '按名称排序',
'Filter Accounts': '过滤账户',
'Filter Transaction Categories': '过滤交易类型',
'User Settings': '用户设置',