mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-20 17:54:30 +08:00
code refactor
This commit is contained in:
@@ -10,7 +10,6 @@ import { mapStores } from 'pinia';
|
|||||||
import { useSettingsStore } from '@/stores/setting.js';
|
import { useSettingsStore } from '@/stores/setting.js';
|
||||||
|
|
||||||
import colorConstants from '@/consts/color.js';
|
import colorConstants from '@/consts/color.js';
|
||||||
import statisticsConstants from '@/consts/statistics.js';
|
|
||||||
import { formatPercent } from '@/lib/common.js';
|
import { formatPercent } from '@/lib/common.js';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -88,7 +87,7 @@ export default {
|
|||||||
actualPercent: item[this.valueField] / totalValidValue,
|
actualPercent: item[this.valueField] / totalValidValue,
|
||||||
currency: item[this.currencyField],
|
currency: item[this.currencyField],
|
||||||
itemStyle: {
|
itemStyle: {
|
||||||
color: this.getColor(item[this.colorField] ? item[this.colorField] : statisticsConstants.defaultChartColors[validItems.length % statisticsConstants.defaultChartColors.length]),
|
color: this.getColor(item[this.colorField] ? item[this.colorField] : colorConstants.defaultChartColors[validItems.length % colorConstants.defaultChartColors.length]),
|
||||||
},
|
},
|
||||||
selected: true,
|
selected: true,
|
||||||
sourceItem: item
|
sourceItem: item
|
||||||
|
|||||||
@@ -81,7 +81,6 @@ import { mapStores } from 'pinia';
|
|||||||
import { useSettingsStore } from '@/stores/setting.js';
|
import { useSettingsStore } from '@/stores/setting.js';
|
||||||
|
|
||||||
import colorConstants from '@/consts/color.js';
|
import colorConstants from '@/consts/color.js';
|
||||||
import statisticsConstants from '@/consts/statistics.js';
|
|
||||||
import { formatPercent } from '@/lib/common.js';
|
import { formatPercent } from '@/lib/common.js';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -141,7 +140,7 @@ export default {
|
|||||||
percent: (item[this.percentField] > 0 || item[this.percentField] === 0 || item[this.percentField] === '0') ? item[this.percentField] : (item[this.valueField] / totalValidValue * 100),
|
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,
|
actualPercent: item[this.valueField] / totalValidValue,
|
||||||
currency: item[this.currencyField],
|
currency: item[this.currencyField],
|
||||||
color: item[this.colorField] ? item[this.colorField] : statisticsConstants.defaultChartColors[validItems.length % statisticsConstants.defaultChartColors.length],
|
color: item[this.colorField] ? item[this.colorField] : colorConstants.defaultChartColors[validItems.length % colorConstants.defaultChartColors.length],
|
||||||
sourceItem: item
|
sourceItem: item
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -16,10 +16,24 @@ const allAvailableColors = [
|
|||||||
'9c27b0', // purple
|
'9c27b0', // purple
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const defaultChartColors = [
|
||||||
|
'cc4a66',
|
||||||
|
'e3564a',
|
||||||
|
'fc892c',
|
||||||
|
'ffc349',
|
||||||
|
'4dd291',
|
||||||
|
'24ceb3',
|
||||||
|
'2ab4d0',
|
||||||
|
'065786',
|
||||||
|
'713670',
|
||||||
|
'8e1d51'
|
||||||
|
];
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
defaultColor: defaultColor,
|
defaultColor: defaultColor,
|
||||||
allAccountColors: allAvailableColors,
|
allAccountColors: allAvailableColors,
|
||||||
defaultAccountColor: defaultColor,
|
defaultAccountColor: defaultColor,
|
||||||
allCategoryColors: allAvailableColors,
|
allCategoryColors: allAvailableColors,
|
||||||
defaultCategoryColor: defaultColor,
|
defaultCategoryColor: defaultColor,
|
||||||
|
defaultChartColors: defaultChartColors,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -64,19 +64,6 @@ const allSortingTypes = {
|
|||||||
|
|
||||||
const defaultSortingType = allSortingTypes.Amount.type;
|
const defaultSortingType = allSortingTypes.Amount.type;
|
||||||
|
|
||||||
const defaultChartColors = [
|
|
||||||
'cc4a66',
|
|
||||||
'e3564a',
|
|
||||||
'fc892c',
|
|
||||||
'ffc349',
|
|
||||||
'4dd291',
|
|
||||||
'24ceb3',
|
|
||||||
'2ab4d0',
|
|
||||||
'065786',
|
|
||||||
'713670',
|
|
||||||
'8e1d51'
|
|
||||||
];
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
allChartTypes: allChartTypes,
|
allChartTypes: allChartTypes,
|
||||||
defaultChartType: defaultChartType,
|
defaultChartType: defaultChartType,
|
||||||
@@ -85,5 +72,4 @@ export default {
|
|||||||
defaultDataRangeType: datetime.allDateRanges.ThisMonth.type,
|
defaultDataRangeType: datetime.allDateRanges.ThisMonth.type,
|
||||||
allSortingTypes: allSortingTypes,
|
allSortingTypes: allSortingTypes,
|
||||||
defaultSortingType: defaultSortingType,
|
defaultSortingType: defaultSortingType,
|
||||||
defaultChartColors: defaultChartColors,
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user