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
};