fix(测试跟踪): 责任人图表宽度自适应

--bug=1033312 --user=白奇 【测试跟踪】首页-用例责任人分布图表不会自适应显示/github #27765 https://www.tapd.cn/55049933/s/1602303
This commit is contained in:
baiqi 2024-10-30 16:24:23 +08:00 committed by Craftsman
parent 90e8b39f73
commit 521f914033
1 changed files with 85 additions and 51 deletions

View File

@ -2,19 +2,39 @@
<div class="dashboard-card"> <div class="dashboard-card">
<el-card shadow="never" class="box-card" style="height: 100%"> <el-card shadow="never" class="box-card" style="height: 100%">
<div slot="header" class="clearfix"> <div slot="header" class="clearfix">
<span class="dashboard-title">{{ $t('test_track.home.case_maintenance') }}</span> <span class="dashboard-title">{{
$t("test_track.home.case_maintenance")
}}</span>
</div> </div>
<div v-loading="loading" element-loading-background="#FFFFFF"> <div v-loading="loading" element-loading-background="#FFFFFF">
<div v-if="loadError" <div
style="width: 100%; height: 300px; display: flex; flex-direction: column; justify-content: center;align-items: center"> v-if="loadError"
<img style="height: 100px;width: 100px;" style="
src="/assets/module/figma/icon_load_error.svg"/> width: 100%;
<span class="addition-info-title" style="color: #646A73">{{ $t("home.dashboard.public.load_error") }}</span> height: 300px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
"
>
<img
style="height: 100px; width: 100px"
src="/assets/module/figma/icon_load_error.svg"
/>
<span class="addition-info-title" style="color: #646a73">{{
$t("home.dashboard.public.load_error")
}}</span>
</div> </div>
<div v-if="!loadError"> <div v-if="!loadError">
<el-container> <el-container>
<ms-chart ref="chart1" :options="caseOption" :autoresize="true" style="width: 100%;height: 340px;"></ms-chart> <ms-chart
ref="chart1"
:options="caseOption"
:autoresize="true"
style="width: 100%; height: 340px"
></ms-chart>
</el-container> </el-container>
</div> </div>
</div> </div>
@ -34,8 +54,8 @@ export default {
return { return {
loading: false, loading: false,
loadError: false, loadError: false,
caseOption: {} caseOption: {},
} };
}, },
activated() { activated() {
this.search(); this.search();
@ -46,104 +66,118 @@ export default {
this.loadError = false; this.loadError = false;
let selectProjectId = getCurrentProjectID(); let selectProjectId = getCurrentProjectID();
getTrackCaseBar(selectProjectId) getTrackCaseBar(selectProjectId)
.then(r => { .then((r) => {
this.loading = false; this.loading = false;
this.loadError = false; this.loadError = false;
let data = r.data; let data = r.data;
this.setBarOption(data); this.setBarOption(data);
}).catch(() => { })
.catch(() => {
this.loading = false; this.loading = false;
this.loadError = true; this.loadError = true;
}); });
}, },
setBarOption(data) { setBarOption(data) {
let xAxis = []; let xAxis = [];
data.map(d => { data.map((d) => {
if (!xAxis.includes(d.xAxis)) { if (!xAxis.includes(d.xAxis)) {
xAxis.push(d.xAxis); xAxis.push(d.xAxis);
} }
}); });
let yAxis1 = data.filter(d => d.groupName === 'FUNCTIONCASE').map(d => [d.xAxis, d.yAxis]); let yAxis1 = data
let yAxis2 = data.filter(d => d.groupName === 'RELEVANCECASE').map(d => [d.xAxis, d.yAxis]); .filter((d) => d.groupName === "FUNCTIONCASE")
.map((d) => [d.xAxis, d.yAxis]);
let yAxis2 = data
.filter((d) => d.groupName === "RELEVANCECASE")
.map((d) => [d.xAxis, d.yAxis]);
let option = { let option = {
tooltip: { tooltip: {
trigger: 'axis', trigger: "axis",
axisPointer: { axisPointer: {
type: 'shadow' type: "shadow",
} },
}, },
xAxis: { xAxis: {
type: 'category', type: "category",
data: xAxis, data: xAxis,
axisTick: { axisTick: {
show:false // 线 show: false, // 线
}, },
}, },
yAxis: { yAxis: {
type: 'value', type: "value",
axisLine: { axisLine: {
show: false show: false,
}, },
axisTick: { axisTick: {
show: false show: false,
}, },
min: 0, min: 0,
max: data.length === 0 ? 40 : null max: data.length === 0 ? 40 : null,
}, },
grid: { grid: {
left: 0, left: 0,
containLabel: true, containLabel: true,
top: 80, top: 80,
right: 24, right: 24,
width: 600, bottom: 24,
height: 255
}, },
legend: { legend: {
itemWidth: 8, itemWidth: 8,
itemHeight: 8, itemHeight: 8,
data: [{icon: 'rect', name: this.$t('test_track.home.function_case_count')}, {icon: 'rect', name: this.$t('test_track.home.relevance_case_count')}], data: [
orient: 'horizontal', {
left: '0', icon: "rect",
top: '24' name: this.$t("test_track.home.function_case_count"),
},
{
icon: "rect",
name: this.$t("test_track.home.relevance_case_count"),
},
],
orient: "horizontal",
left: "0",
top: "24",
}, },
series: [ series: [
{ {
name: this.$t('test_track.home.function_case_count'), name: this.$t("test_track.home.function_case_count"),
data: yAxis1, data: yAxis1,
type: 'bar', type: "bar",
barWidth: 16, barWidth: 16,
barMinHeight: 5, barMinHeight: 5,
itemStyle: { itemStyle: {
color: '#AA4FBF', color: "#AA4FBF",
barBorderRadius: [2, 2, 0, 0] barBorderRadius: [2, 2, 0, 0],
} },
}, },
{ {
name: this.$t('test_track.home.relevance_case_count'), name: this.$t("test_track.home.relevance_case_count"),
data: yAxis2, data: yAxis2,
type: 'bar', type: "bar",
barWidth: 16, barWidth: 16,
barMinHeight: 5, barMinHeight: 5,
itemStyle: { itemStyle: {
color: '#F9CB2E', color: "#F9CB2E",
barBorderRadius: [2, 2, 0, 0] barBorderRadius: [2, 2, 0, 0],
} },
}] },
],
}; };
this.caseOption = option; this.caseOption = option;
}, },
} },
} };
</script> </script>
<style scoped> <style scoped>
.no-shadow-card { .no-shadow-card {
-webkit-box-shadow: 0 0px 0px 0 rgba(0,0,0,.1); -webkit-box-shadow: 0 0px 0px 0 rgba(0, 0, 0, 0.1);
box-shadow: 0 0px 0px 0 rgba(0,0,0,.1); box-shadow: 0 0px 0px 0 rgba(0, 0, 0, 0.1);
} }
.el-card :deep(.el-card__header) { .el-card :deep(.el-card__header) {
border-bottom: 0px solid #EBEEF5; border-bottom: 0px solid #ebeef5;
padding-bottom: 0px; padding-bottom: 0px;
} }
</style> </style>