fix(工作台): 修复柱状图bug

This commit is contained in:
xinxin.wu 2024-11-19 13:10:03 +08:00 committed by 刘瑞斌
parent 97318ee4b2
commit 8289daf30f
6 changed files with 89 additions and 44 deletions

View File

@ -87,12 +87,14 @@
const { openNewPage } = useOpenNewPage(); const { openNewPage } = useOpenNewPage();
const reviewStatusOptions = computed(() => { const reviewStatusOptions = computed(() => {
return Object.keys(reviewStatusMap).map((key) => { const keys = Object.keys(reviewStatusMap).filter((key) => {
return { return props.type !== 'my_todo' || key !== 'COMPLETED';
value: key,
label: t(reviewStatusMap[key as ReviewStatus].label),
};
}); });
return keys.map((key) => ({
value: key,
label: t(reviewStatusMap[key as ReviewStatus].label),
}));
}); });
const columns: MsTableColumn = [ const columns: MsTableColumn = [

View File

@ -14,7 +14,7 @@
<a-button type="secondary" @click="exitHandler"> <a-button type="secondary" @click="exitHandler">
{{ t('workbench.homePage.exitEdit') }} {{ t('workbench.homePage.exitEdit') }}
</a-button> </a-button>
<a-button type="primary" :disabled="!selectedCardList.length" :loading="confirmLoading" @click="saveHandler"> <a-button type="primary" :loading="confirmLoading" @click="saveHandler">
{{ t('common.save') }} {{ t('common.save') }}
</a-button> </a-button>
</div> </div>

View File

@ -52,7 +52,7 @@
import type { OverViewOfProject, SelectedCardItem, TimeFormParams } from '@/models/workbench/homePage'; import type { OverViewOfProject, SelectedCardItem, TimeFormParams } from '@/models/workbench/homePage';
import { commonColorConfig, getCommonBarOptions, handleNoDataDisplay } from '../utils'; import { getColorScheme, getCommonBarOptions, handleNoDataDisplay } from '../utils';
import type { SelectOptionData } from '@arco-design/web-vue'; import type { SelectOptionData } from '@arco-design/web-vue';
const { t } = useI18n(); const { t } = useI18n();
@ -93,7 +93,10 @@
const defectStatusColor = ['#811FA3', '#FFA200', '#3370FF', '#F24F4F']; const defectStatusColor = ['#811FA3', '#FFA200', '#3370FF', '#F24F4F'];
function handleData(detail: OverViewOfProject) { function handleData(detail: OverViewOfProject) {
options.value = getCommonBarOptions(detail.xaxis.length >= 7, [...defectStatusColor, ...commonColorConfig]); options.value = getCommonBarOptions(detail.xaxis.length >= 7, [
...defectStatusColor,
...getColorScheme(detail.xaxis.length),
]);
const { invisible, text } = handleNoDataDisplay(detail.xaxis, detail.projectCountList); const { invisible, text } = handleNoDataDisplay(detail.xaxis, detail.projectCountList);
options.value.graphic.invisible = invisible; options.value.graphic.invisible = invisible;
options.value.graphic.style.text = text; options.value.graphic.style.text = text;

View File

@ -56,7 +56,7 @@
} from '@/models/workbench/homePage'; } from '@/models/workbench/homePage';
import { WorkCardEnum, WorkOverviewEnum } from '@/enums/workbenchEnum'; import { WorkCardEnum, WorkOverviewEnum } from '@/enums/workbenchEnum';
import { commonColorConfig, getCommonBarOptions, handleNoDataDisplay } from '../utils'; import { getColorScheme, getCommonBarOptions, handleNoDataDisplay } from '../utils';
const { t } = useI18n(); const { t } = useI18n();
@ -108,7 +108,7 @@
}); });
cardModuleList.value = tempAxisData as ModuleCardItem[]; cardModuleList.value = tempAxisData as ModuleCardItem[];
options.value = getCommonBarOptions(hasRoom.value, commonColorConfig); options.value = getCommonBarOptions(hasRoom.value, getColorScheme(detail.projectCountList.length));
const { invisible, text } = handleNoDataDisplay(detail.xaxis, detail.projectCountList); const { invisible, text } = handleNoDataDisplay(detail.xaxis, detail.projectCountList);
options.value.graphic.invisible = invisible; options.value.graphic.invisible = invisible;
options.value.graphic.style.text = text; options.value.graphic.style.text = text;

View File

@ -57,7 +57,7 @@
import type { OverViewOfProject, SelectedCardItem, TimeFormParams } from '@/models/workbench/homePage'; import type { OverViewOfProject, SelectedCardItem, TimeFormParams } from '@/models/workbench/homePage';
import { commonColorConfig, getCommonBarOptions, handleNoDataDisplay } from '../utils'; import { getColorScheme, getCommonBarOptions, handleNoDataDisplay } from '../utils';
const { t } = useI18n(); const { t } = useI18n();
const appStore = useAppStore(); const appStore = useAppStore();
@ -92,8 +92,9 @@
const memberOptions = ref<{ label: string; value: string }[]>([]); const memberOptions = ref<{ label: string; value: string }[]>([]);
const options = ref<Record<string, any>>({}); const options = ref<Record<string, any>>({});
const color = ['#811FA3', '#FFCA59', '#00C261', '#FFA1FF', '#F9F871', '#3370FF', '#F24F4F'];
function handleData(detail: OverViewOfProject) { function handleData(detail: OverViewOfProject) {
options.value = getCommonBarOptions(detail.xaxis.length >= 7, commonColorConfig); options.value = getCommonBarOptions(detail.xaxis.length >= 7, color);
const { invisible, text } = handleNoDataDisplay(detail.xaxis, detail.projectCountList); const { invisible, text } = handleNoDataDisplay(detail.xaxis, detail.projectCountList);
options.value.graphic.invisible = invisible; options.value.graphic.invisible = invisible;
options.value.graphic.style.text = text; options.value.graphic.style.text = text;
@ -209,7 +210,6 @@
(val) => { (val) => {
if (val) { if (val) {
innerHandleUsers.value = val; innerHandleUsers.value = val;
initOverViewMemberDetail();
} }
} }
); );

View File

@ -9,37 +9,56 @@ import { WorkCardEnum } from '@/enums/workbenchEnum';
const { t } = useI18n(); const { t } = useI18n();
// 通用颜色配置 // 通用颜色配置
export const commonColorConfig = [ const commonColorConfig: Record<number, string[]> = {
'#783887', 2: ['#783887', '#FFC14E'],
'#FFC14E', 4: ['#783887', '#FFC14E', '#2DFCEF', '#3370FF'],
'#2DFCEF', 8: ['#783887', '#FFC14E', '#2DFCEF', '#3370FF', '#811FA3', '#00D1FF', '#FFA53D', '#00C261'],
'#811FA3', 12: [
'#00D1FF', '#AA4FBF',
'#FFA53D', '#FFA1FF',
'#00C261', '#EE50A3',
'#AA4FBF', '#FF9964',
'#FFA1FF', '#FFCA59',
'#EE50A3', '#F9F871',
'#FF9964', '#C3DD40',
'#FFCA59', '#62D256',
'#F9F871', '#14E1C6',
'#C3DD40', '#50CEFB',
'#62D256', '#3370FF',
'#14E1C6', '#2B5FD9',
'#50CEFB', ],
'#3370FF', 13: [
'#2B5FD9', '#AA4FBF',
'#76F0FF', '#FFA1FF',
'#935AF6', '#FFCA59',
'#DC9BFF', '#F9F871',
'#FFC75E', '#14E1C6',
'#D34400', '#2DFCEF',
'#F4D0BF', '#2B5FD9',
'#FBD3E8', '#00D1FF',
'#D9F457', '#935AF6',
'#0089D1', '#DC9BFF',
'#87F578', '#FF9964',
]; '#FFC75E',
'#D34400',
'#F4D0BF',
'#EE50A3',
'#FBD3E8',
'#C3DD40',
'#D9F457',
'#0089D1',
'#62D256',
'#87F578',
],
};
export function getColorScheme(dataLength: number): string[] {
if (dataLength <= 2) return commonColorConfig[2];
if (dataLength <= 4) return commonColorConfig[4];
if (dataLength <= 8) return commonColorConfig[8];
if (dataLength <= 12) return commonColorConfig[12];
return commonColorConfig[13];
}
// 饼图颜色配置 // 饼图颜色配置
export const colorMapConfig: Record<string, string[]> = { export const colorMapConfig: Record<string, string[]> = {
@ -184,6 +203,27 @@ export function getCommonBarOptions(hasRoom: boolean, color: string[]): Record<s
color: '#00000099', color: '#00000099',
fontSize: 12, fontSize: 12,
}, },
textStyle: {
width: 150,
overflow: 'truncate',
ellipsis: '...',
},
formatter(name: string) {
return name;
},
tooltip: {
show: true,
padding: 16,
position(point: any) {
return [point[0], '10%'];
},
extraCssText: 'max-width: 300px; white-space: normal; word-wrap: break-word; word-break: break-all;',
textStyle: {
width: 300,
fontSize: 12,
overflow: 'breakAll',
},
},
}, },
dataZoom: hasRoom dataZoom: hasRoom
? [ ? [