Commit c8bc5296480765d47ec48a96e25ed74316160b0f
Committed by
xp.Huang
1 parent
2a30762e
fix: 修复Api调用统计数值显示
Showing
5 changed files
with
22 additions
and
10 deletions
... | ... | @@ -17,6 +17,7 @@ export default { |
17 | 17 | numberOfFailedAttempts: 'Number of failed attempts', |
18 | 18 | lineTitle: 'Top Five API calls', |
19 | 19 | pieTitle: 'Proportion of API calls', |
20 | + pieShowTitle: 'Proportion App', | |
20 | 21 | timeLineTitle: 'Interface call history', |
21 | 22 | timeSelect: { |
22 | 23 | oneHour: 'One Hour', | ... | ... |
... | ... | @@ -15,7 +15,8 @@ export default { |
15 | 15 | numberOfSuccessfulAttempts: '成功次数', |
16 | 16 | numberOfFailedAttempts: '失败次数', |
17 | 17 | lineTitle: 'API调用Top5', |
18 | - pieTitle: 'API调用占比', | |
18 | + pieTitle: 'API调用总占比', | |
19 | + pieShowTitle: '应用占比', | |
19 | 20 | timeLineTitle: '接口调用历史', |
20 | 21 | timeSelect: { |
21 | 22 | oneHour: '1小时', | ... | ... |
... | ... | @@ -4,14 +4,15 @@ |
4 | 4 | import { useAppStore } from '/@/store/modules/app'; |
5 | 5 | import { useI18n } from '/@/hooks/web/useI18n'; |
6 | 6 | |
7 | - const { t } = useI18n(); | |
8 | - | |
9 | 7 | const props = defineProps({ |
10 | 8 | seriesData: { |
11 | 9 | type: Array, |
12 | 10 | default: () => [], |
13 | 11 | }, |
14 | 12 | }); |
13 | + | |
14 | + const { t } = useI18n(); | |
15 | + | |
15 | 16 | const appStore = useAppStore(); |
16 | 17 | |
17 | 18 | const skinName = computed(() => { |
... | ... | @@ -40,7 +41,7 @@ |
40 | 41 | }, |
41 | 42 | title: [ |
42 | 43 | { |
43 | - text: t('application.record.text.totalNumberOfCalls'), | |
44 | + text: t('application.record.text.pieShowTitle'), | |
44 | 45 | textStyle: { |
45 | 46 | color: '#333', |
46 | 47 | fontWeight: 'bold', |
... | ... | @@ -69,7 +70,9 @@ |
69 | 70 | textStyle: { |
70 | 71 | fontSize: 13, |
71 | 72 | }, |
72 | - formatter: '{d}%', | |
73 | + formatter: (params) => { | |
74 | + return params.value + '%'; | |
75 | + }, | |
73 | 76 | }, |
74 | 77 | }, |
75 | 78 | }, | ... | ... |
... | ... | @@ -61,17 +61,24 @@ |
61 | 61 | label: topItem.name, |
62 | 62 | value: topItem.recordNum, |
63 | 63 | })); |
64 | - chartData.pieChartData = res.tops?.slice(0, 4)?.map((topItem: TopItemType) => ({ | |
64 | + // 取服务端前5个数据 | |
65 | + chartData.pieChartData = res.tops?.slice(0, 5)?.map((topItem: TopItemType) => ({ | |
65 | 66 | name: topItem.name, |
66 | 67 | value: topItem.recordProportion, |
67 | 68 | })); |
68 | - // 总共Top5,取服务端前4个数据,加上其他应用 | |
69 | - const otherApplicationCount = chartData.pieChartData | |
69 | + // 其他应用等于取服务端数组长度为5后面所有数值相加 | |
70 | + const otherApplicationCount = res?.tops | |
71 | + ?.slice(5) | |
72 | + ?.map((topItem: TopItemType) => ({ | |
73 | + name: topItem.name, | |
74 | + value: topItem.recordProportion, | |
75 | + })) | |
70 | 76 | ?.map((topItem) => topItem.value) |
71 | 77 | ?.reduce((sum, curr) => sum + curr); |
78 | + // 相加总共 | |
72 | 79 | chartData.pieChartData.push({ |
73 | 80 | name: '其他应用', |
74 | - value: 100 - otherApplicationCount, | |
81 | + value: res.tops.length <= 5 ? 0 : otherApplicationCount, | |
75 | 82 | }); |
76 | 83 | } |
77 | 84 | }; | ... | ... |