This commit is contained in:
hh 2024-03-27 19:12:05 +08:00
parent 7e7c31417f
commit c90db7414d
2 changed files with 59 additions and 72 deletions

View File

@ -10,7 +10,7 @@
<a-row :gutter="24"> <a-row :gutter="24">
<a-col :xl="24" :style="{ marginBottom: '24px' }"> <a-col :xl="24" :style="{ marginBottom: '24px' }">
<div class="container"> <div class="container">
<div id="map1" style="width: 660px; height: 400px;"></div> <div id="map1" style="width: 100%; height: 400px;"></div>
</div> </div>
</a-col> </a-col>
</a-row> </a-row>
@ -44,13 +44,19 @@ export default {
}; };
}, },
methods: { methods: {
dataChart() { dataChart(data) {
// domecharts main let xData = [];
let yData = [];
for (let key in data) {
xData.push(key);
// %
yData.push((data[key] * 100).toFixed(2));
}
let myChart = echarts.init(document.getElementById("map1")); let myChart = echarts.init(document.getElementById("map1"));
// //
let option = { let option = {
title: { title: {
text: "总上座人数对比", text: "本批次学院通过率排名",
}, },
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
@ -58,37 +64,34 @@ export default {
type: 'shadow' type: 'shadow'
} }
}, },
legend: { grid: {
data: ["英国", "中国"],// left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
}, },
xAxis: { xAxis: [
data: ["一级", "二级", "三级", "四级"], {
axisLabel: { type: 'category',
interval: 0, data: xData,
// rotate: 30 axisTick: {
alignWithLabel: true
} }
}, }
yAxis: { ],
name: '总上座人数(万)', yAxis: [
}, {
type: 'value'
}
],
series: [ series: [
{ {
name: "英国", name: 'Direct',
type: "bar", type: 'bar',
data: [1450, 1100, 450, 300], barWidth: '60%',
label: { data: yData
formatter: '{@value}'
} }
}, ]
{
name: "中国",
type: "bar",
data: [552, 180, 200, 0],
label: {
formatter: '{@value}'
}
},
],
}; };
// 使 // 使
myChart.setOption(option); myChart.setOption(option);
@ -96,33 +99,31 @@ export default {
// //
async getBatch() { async getBatch() {
const getBatch = await defHttp.get({ url: this.Url.getBatch }); const getBatch = await defHttp.get({ url: this.Url.getBatch });
this.batchOptions = getBatch.batches; this.batchOptions = getBatch.batches;
this.batch = this.batchOptions[0].value; this.batch = this.batchOptions[0].value;
this.level = this.levelOptions[0].value; this.level = this.levelOptions[0].value;
this.query(); this.query();
}, },
// //
async query() { async query() {
let data = null;
try { try {
this.loading = true; this.loading = true;
let params = { let params = {
batch: this.batch, batch: this.batch,
level: 'cet4' level: 'cet4'
} }
const data = await defHttp.get({ url: this.Url.getRate, params }); data = await defHttp.get({ url: this.Url.getRate, params });
} finally { } finally {
this.loading = false; this.loading = false;
this.$nextTick(() => { this.$nextTick(() => {
this.dataChart(); this.dataChart(data);
}) })
} }
} }
}, },
mounted() { mounted() {
this.getBatch(); this.getBatch();
this.dataChart();
} }
} }

View File

@ -3,15 +3,13 @@
<a-card title="按批次分析" :loading="loading" :bordered="false"> <a-card title="按批次分析" :loading="loading" :bordered="false">
<template #extra> <template #extra>
<a-select v-model:value="college" style="width: 300px" :options="collegeOptions"></a-select> <a-select v-model:value="college" style="width: 300px" :options="collegeOptions"></a-select>
<!-- <a-select v-model:value="batch" style="margin-left: 10px;width: 120px" :options="batchOptions"></a-select> -->
<!-- <a-select v-model:value="level" style="margin-left: 10px;width: 120px" :options="levelOptions"></a-select> -->
<a-button style="margin-left: 10px;" type="primary" @click="query">查询</a-button> <a-button style="margin-left: 10px;" type="primary" @click="query">查询</a-button>
</template> </template>
<div> <div>
<a-row :gutter="24"> <a-row :gutter="24">
<a-col :xl="24" :style="{ marginBottom: '24px' }"> <a-col :xl="24" :style="{ marginBottom: '24px' }">
<div class="container"> <div class="container">
<div id="map1" style="width: 660px; height: 400px;"></div> <div id="map1" style="width: 100%; height: 400px;"></div>
</div> </div>
</a-col> </a-col>
</a-row> </a-row>
@ -46,13 +44,23 @@ export default {
}; };
}, },
methods: { methods: {
dataChart() { dataChart(data) {
// domecharts main let xData = [];
let yData = [];
for (let key in data) {
xData.push(key);
// %
yData.push((data[key] * 100).toFixed(2));
}
let myChart = echarts.init(document.getElementById("map1")); let myChart = echarts.init(document.getElementById("map1"));
// //
let option = { let option = {
title: { title: {
text: "总上座人数对比", text: "学院通过率变化",
},
xAxis: {
type: 'category',
data: xData,
}, },
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
@ -60,37 +68,15 @@ export default {
type: 'shadow' type: 'shadow'
} }
}, },
legend: {
data: ["英国", "中国"],//
},
xAxis: {
data: ["一级", "二级", "三级", "四级"],
axisLabel: {
interval: 0,
// rotate: 30
}
},
yAxis: { yAxis: {
name: '总上座人数(万)', type: 'value'
}, },
series: [ series: [
{ {
name: "英国", data: yData,
type: "bar", type: 'line'
data: [1450, 1100, 450, 300],
label: {
formatter: '{@value}'
} }
}, ]
{
name: "中国",
type: "bar",
data: [552, 180, 200, 0],
label: {
formatter: '{@value}'
}
},
],
}; };
// 使 // 使
myChart.setOption(option); myChart.setOption(option);
@ -109,24 +95,24 @@ export default {
}, },
// //
async query() { async query() {
let data = null;
try { try {
this.loading = true; this.loading = true;
let params = { let params = {
college: this.college, college: this.college,
level: 'cet4' level: 'cet4'
} }
const data = await defHttp.get({ url: this.Url.getRate, params }); data = await defHttp.get({ url: this.Url.getRate, params });
} finally { } finally {
this.loading = false; this.loading = false;
this.$nextTick(() => { this.$nextTick(() => {
this.dataChart(); this.dataChart(data);
}) })
} }
} }
}, },
mounted() { mounted() {
this.getBatch(); this.getBatch();
this.dataChart();
} }
} }