Commit ee856643394a0da2bdf73c390c240ad5a178e1ac

Authored by xp.Huang
2 parents 2a30762e c8bc5296

Merge branch 'perf/application/24-10-08' into 'main_dev'

fix: 修复Api调用统计数值显示

See merge request yunteng/thingskit-front!1496
@@ -17,6 +17,7 @@ export default { @@ -17,6 +17,7 @@ export default {
17 numberOfFailedAttempts: 'Number of failed attempts', 17 numberOfFailedAttempts: 'Number of failed attempts',
18 lineTitle: 'Top Five API calls', 18 lineTitle: 'Top Five API calls',
19 pieTitle: 'Proportion of API calls', 19 pieTitle: 'Proportion of API calls',
  20 + pieShowTitle: 'Proportion App',
20 timeLineTitle: 'Interface call history', 21 timeLineTitle: 'Interface call history',
21 timeSelect: { 22 timeSelect: {
22 oneHour: 'One Hour', 23 oneHour: 'One Hour',
@@ -15,7 +15,8 @@ export default { @@ -15,7 +15,8 @@ export default {
15 numberOfSuccessfulAttempts: '成功次数', 15 numberOfSuccessfulAttempts: '成功次数',
16 numberOfFailedAttempts: '失败次数', 16 numberOfFailedAttempts: '失败次数',
17 lineTitle: 'API调用Top5', 17 lineTitle: 'API调用Top5',
18 - pieTitle: 'API调用占比', 18 + pieTitle: 'API调用总占比',
  19 + pieShowTitle: '应用占比',
19 timeLineTitle: '接口调用历史', 20 timeLineTitle: '接口调用历史',
20 timeSelect: { 21 timeSelect: {
21 oneHour: '1小时', 22 oneHour: '1小时',
@@ -4,14 +4,15 @@ @@ -4,14 +4,15 @@
4 import { useAppStore } from '/@/store/modules/app'; 4 import { useAppStore } from '/@/store/modules/app';
5 import { useI18n } from '/@/hooks/web/useI18n'; 5 import { useI18n } from '/@/hooks/web/useI18n';
6 6
7 - const { t } = useI18n();  
8 -  
9 const props = defineProps({ 7 const props = defineProps({
10 seriesData: { 8 seriesData: {
11 type: Array, 9 type: Array,
12 default: () => [], 10 default: () => [],
13 }, 11 },
14 }); 12 });
  13 +
  14 + const { t } = useI18n();
  15 +
15 const appStore = useAppStore(); 16 const appStore = useAppStore();
16 17
17 const skinName = computed(() => { 18 const skinName = computed(() => {
@@ -40,7 +41,7 @@ @@ -40,7 +41,7 @@
40 }, 41 },
41 title: [ 42 title: [
42 { 43 {
43 - text: t('application.record.text.totalNumberOfCalls'), 44 + text: t('application.record.text.pieShowTitle'),
44 textStyle: { 45 textStyle: {
45 color: '#333', 46 color: '#333',
46 fontWeight: 'bold', 47 fontWeight: 'bold',
@@ -69,7 +70,9 @@ @@ -69,7 +70,9 @@
69 textStyle: { 70 textStyle: {
70 fontSize: 13, 71 fontSize: 13,
71 }, 72 },
72 - formatter: '{d}%', 73 + formatter: (params) => {
  74 + return params.value + '%';
  75 + },
73 }, 76 },
74 }, 77 },
75 }, 78 },
@@ -70,7 +70,7 @@ @@ -70,7 +70,7 @@
70 }, 70 },
71 yAxis: { 71 yAxis: {
72 type: 'value', 72 type: 'value',
73 - axisLabel: { formatter: '{value} %' }, 73 + axisLabel: { formatter: '{value}' },
74 }, 74 },
75 series: props.seriesData, 75 series: props.seriesData,
76 }; 76 };
@@ -61,17 +61,24 @@ @@ -61,17 +61,24 @@
61 label: topItem.name, 61 label: topItem.name,
62 value: topItem.recordNum, 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 name: topItem.name, 66 name: topItem.name,
66 value: topItem.recordProportion, 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 ?.map((topItem) => topItem.value) 76 ?.map((topItem) => topItem.value)
71 ?.reduce((sum, curr) => sum + curr); 77 ?.reduce((sum, curr) => sum + curr);
  78 + // 相加总共
72 chartData.pieChartData.push({ 79 chartData.pieChartData.push({
73 name: '其他应用', 80 name: '其他应用',
74 - value: 100 - otherApplicationCount, 81 + value: res.tops.length <= 5 ? 0 : otherApplicationCount,
75 }); 82 });
76 } 83 }
77 }; 84 };