fix(工作台): 修复工作台成员概览柱状图bug

This commit is contained in:
xinxin.wu 2024-11-19 10:54:00 +08:00 committed by Craftsman
parent f55e108ad2
commit 9aef19c9cf
3 changed files with 33 additions and 12 deletions

View File

@ -123,6 +123,7 @@
return { return {
name: item.name, name: item.name,
value: e, value: e,
originValue: e,
tooltip: { tooltip: {
show: true, show: true,
trigger: 'item', trigger: 'item',

View File

@ -98,23 +98,44 @@
options.value.graphic.invisible = invisible; options.value.graphic.invisible = invisible;
options.value.graphic.style.text = text; options.value.graphic.style.text = text;
options.value.xAxis.data = detail.xaxis.map((e) => characterLimit(e, 10)); options.value.xAxis.data = detail.xaxis.map((e) => characterLimit(e, 10));
let maxAxis = 5;
options.value.series = detail.projectCountList.map((item, index) => {
const itemMax = Math.max(...item.count);
maxAxis = Math.max(itemMax, maxAxis); const rawData: number[][] = [];
detail.projectCountList.forEach((item: any) => {
rawData.push(item.count);
});
const totalData: number[] = [];
for (let i = 0; i < rawData[0].length; ++i) {
let sum = 0;
for (let j = 0; j < rawData.length; ++j) {
sum += rawData[j][i];
}
totalData.push(sum);
}
options.value.series = detail.projectCountList.map((item, sid) => {
const dataList = rawData[sid].map((d, did) => (totalData[did] <= 0 ? 0 : d / totalData[did]));
const data = dataList.map((e, i) => {
return { return {
name: t(contentTabList[index].label), name: t(contentTabList[sid].label),
value: e,
originValue: item.count[i],
};
});
return {
name: t(contentTabList[sid].label),
type: 'bar', type: 'bar',
stack: 'member', stack: 'total',
barWidth: 12, barWidth: 12,
data: item.count,
itemStyle: { itemStyle: {
borderRadius: [2, 2, 0, 0], borderRadius: [2, 2, 0, 0],
}, },
data,
}; };
}); });
options.value.yAxis[0].max = maxAxis < 100 ? 50 : maxAxis + 50;
} }
async function initOverViewMemberDetail() { async function initOverViewMemberDetail() {

View File

@ -84,7 +84,7 @@ export function getCommonBarOptions(hasRoom: boolean, color: string[]): Record<s
<div class="mb-[2px] mr-[8px] h-[8px] w-[8px] rounded-sm" style="background:${item.color}"></div> <div class="mb-[2px] mr-[8px] h-[8px] w-[8px] rounded-sm" style="background:${item.color}"></div>
<div class="one-line-text max-w-[100px]" style="color:#959598">${item.seriesName}</div> <div class="one-line-text max-w-[100px]" style="color:#959598">${item.seriesName}</div>
</div> </div>
<div class="text-[#323233] font-medium">${addCommasToNumber(item.value || 0)}</div> <div class="text-[#323233] font-medium">${addCommasToNumber(item.data.originValue || 0)}</div>
</div> </div>
` `
) )
@ -124,9 +124,8 @@ export function getCommonBarOptions(hasRoom: boolean, color: string[]): Record<s
}, },
yAxis: [ yAxis: [
{ {
type: 'log', type: 'value',
alignTicks: true, alignTicks: true,
logBase: 250,
name: t('workbench.homePage.unit'), // 设置单位 name: t('workbench.homePage.unit'), // 设置单位
position: 'left', position: 'left',
axisLine: { axisLine: {
@ -148,7 +147,7 @@ export function getCommonBarOptions(hasRoom: boolean, color: string[]): Record<s
type: 'dashed', // 水平线线型,可选 'solid'、'dashed'、'dotted' type: 'dashed', // 水平线线型,可选 'solid'、'dashed'、'dotted'
}, },
}, },
min: 1, min: 0,
max: 0, max: 0,
}, },
], ],