add:用时分析改为柱状图;

This commit is contained in:
小杨 2024-10-24 14:36:35 +08:00
parent 8a759479bd
commit eba6727dc0
7 changed files with 144 additions and 172 deletions

View File

@ -4,12 +4,17 @@ const overviewStore = defineStore(
{
state: () => {
return {
tableList:[]
tableList:[],
allData:[]
}
},
actions: {
getTableList(data){
this.tableList = [...data]
},
//整理的所有列表
getAllData(data){
this.allData = [...data]
}
}
})

View File

@ -370,7 +370,7 @@ const eventHandles = (type, win) => {
export const toLinkWeb = (path) => {
const config = baseConfig()
// console.log(config)
const fullPath = config.url + path
const fullPath = ' https://localhost:7860/' + path
// 通知主进程
ipcRenderer.send('openWindow', {
key: `win-${Date.now()}`,

View File

@ -10,7 +10,7 @@
等级分布
</div>
</template>
<Distribution :stuHasAnswers=stuHasAnswers></Distribution>
<Distribution></Distribution>
</el-card>
</el-header>
<el-main>
@ -72,7 +72,6 @@ const props = defineProps({
},
})
let studentList = ref([]) //
const stuHasAnswers = ref([]) //
// -
const initData = () => {
@ -81,6 +80,7 @@ const initData = () => {
studentList.value = props.activeData.studentList || []
const activeWorkFeedList = props.activeData.workFeedList || []
const quizlist = props.activeData.quizlist || []
const timeArr = groupByField(props.activeData.workFeedList,'entpcourseworkid')
//
let data = quizlist.map(o => {
//
@ -91,6 +91,13 @@ const initData = () => {
let hasAnswers= [] //
let timeAnalyse = [] //
const quizFeedList = activeWorkFeedList.filter(f => f.entpcourseworkid == o.id) //
//
timeArr.forEach((item,index) => {
const arr = item.reduce((acc, cur) => {
return acc + (cur.timelength ? Number(cur.timelength) : 0);
},0)
timeAnalyse.push(arr)
})
let children = []
const allStudents = [];
if (o.worktype == '单选题') { // '',''
@ -215,12 +222,10 @@ const initData = () => {
}
// def: type active: points: , accSum
return { def: o, id: o.id, type: o.worktype, active: [], points, accSum, rightSum, children,hasAnswers }
return { def: o, id: o.id, type: o.worktype, active: [], points, accSum, rightSum, children,hasAnswers,timeAnalyse }
})
console.log('获取数据: ', data)
if (data.length === 0) return
if (!data[0].hasAnswers[0]) return
stuHasAnswers.value = [...data[0].hasAnswers]
useOverview.getAllData([...data])
}
// 0-100
const percent = v => v > 1 ? 1 : v < 0 ? 0 : Math.round(v * 100)
@ -233,6 +238,20 @@ const isJson = str => {if(typeof str == 'string'){
if(typeof res == 'object' && res) return true
} catch (error) {}}return false
}
//
const groupByField = (array, field) => {
const groupedMap = {};
array.forEach(item => {
const key = item[field];
if (!groupedMap[key]) {
groupedMap[key] = [];
}
groupedMap[key].push(item);
});
//
return Object.values(groupedMap);
}
watch(() => props.tableList,() => {
useOverview.getTableList(props.tableList)

View File

@ -3,26 +3,19 @@
<el-container>
<el-aside width="400px">
<!-- 柱状图学情分布-->
<Echarts :stuHasAnswers=stuHasAnswers></Echarts>
<Echarts></Echarts>
</el-aside>
<el-main>
<!-- 列表分布的人员-->
<StuList :stuHasAnswers=stuHasAnswers></StuList>
<StuList></StuList>
</el-main>
</el-container>
</div>
</template>
<script setup>
import { defineProps } from 'vue'
import Echarts from './distribution/echarts.vue'
import StuList from "./distribution/stuList.vue";
const props = defineProps({
stuHasAnswers: {
type: Array,
default: () => []
}
})
</script>
<style scoped>

View File

@ -5,7 +5,7 @@
</template>
<script setup>
import { ref, nextTick, watch, inject,watchEffect } from 'vue';
import { ref, nextTick, watch } from 'vue';
import * as echarts from 'echarts';
import overviewStore from '@/store/modules/overview';
const useOverview = overviewStore();
@ -13,13 +13,6 @@ const useOverview = overviewStore();
//
const chartRef = ref(null);
const props = defineProps({
stuHasAnswers: {
type: Array,
default: () => []
}
})
//
const dataList = ref([
{ name: '完美', value: 0, rating: 1, max: 100, min: 100 },
@ -111,7 +104,7 @@ const showEcharts = () => {
}
//
watch(() => useOverview.tableList, () => {
hasStudents.value = useOverview.tableList.filter(item => props.stuHasAnswers.includes(item.studentid)).map(item => item);
hasStudents.value = useOverview.tableList.filter(item => useOverview.allData[0].hasAnswers.includes(item.studentid)).map(item => item);
showEcharts();
nextTick(() => {
initChart();

View File

@ -22,12 +22,6 @@ import overviewStore from '@/store/modules/overview'
const useOverview = overviewStore()
const tabPosition = ref('left')
const props = defineProps({
stuHasAnswers: {
type: Array,
default: () => []
}
})
//
const hasStudents = ref([])
const leftList = ref([
@ -87,7 +81,7 @@ const showStudents = (index) => {
})
}
watch(() => useOverview.tableList, () => {
hasStudents.value = useOverview.tableList.filter(item => props.stuHasAnswers.includes(item.studentid)).map(item => item);
hasStudents.value = useOverview.tableList.filter(item => useOverview.allData[0].hasAnswers.includes(item.studentid)).map(item => item);
showStudents(0)
},{deep: true})
</script>

View File

@ -14,156 +14,124 @@ const useOverview = overviewStore()
//
const chartRef = ref(null);
const estimateTime = ref([]);
const avaterTime = ref([]);
// x
const xAxisData = ref([]);
// y
const getyAxisData = () => {
estimateTime.value = [];
avaterTime.value = [];
useOverview.tableList.forEach(item => {
if (item.rating !== 0) {
estimateTime.value.push({
name: item.scoingRate ? item.scoingRate + '%' : 0 + '%',
value: Number(item.timelength)
});
avaterTime.value.push({
name: item.scoingRate ? item.scoingRate + '%' : 0 + '%',
value: Number(item.finishtimelength)
});
}
});
// x
xAxisData.value.sort((a, b) => {
const aPercentage = parseInt(a.replace('%', ''));
const bPercentage = parseInt(b.replace('%', ''));
return aPercentage - bPercentage;
});
// x
generateXAxisData();
};
// x
function generateXAxisData() {
// 8x
if(estimateTime.value.length > 8){
const minScoreRate = 0;
const maxScoreRate = 100;
const numPoints = 6; // x
const step = (maxScoreRate - minScoreRate) / (numPoints - 1);
xAxisData.value = [];
for (let i = 0; i < numPoints; i++) {
const scoreRate = minScoreRate + i * step;
xAxisData.value.push(scoreRate + '%');
}
}else{
let uniqueXAxisData = new Set();
estimateTime.value.forEach(item => {
// Set
uniqueXAxisData.add(item.name);
});
// Set
xAxisData.value = Array.from(uniqueXAxisData);
//
xAxisData.value.sort((a, b) => {
const aPercentage = parseInt(a.replace('%', ''));
const bPercentage = parseInt(b.replace('%', ''));
return aPercentage - bPercentage;
});
}
}
//
function initChart() {
const myChart = echarts.init(chartRef.value);
const options = {
//
let option = {
tooltip: {
trigger: 'axis',
trigger: "axis",
axisPointer: {
type: 'cross'
}
type: "shadow", // 线'line' | 'shadow'
},
legend: {
data: ['预估时长', '平均用时']
formatter: function(parms) {
let str =
parms[0].axisValue +
"</br>" +
parms[0].marker +
"平均用时:" +
parms[0].value + 's'
return str;
},
},
textStyle: {
color: "#333",
},
color: ["#7BA9FA", "#4690FA"],
grid: {
left: '3%',
right: '4%',
bottom: '3%',
top: '10%',
containLabel: true
containLabel: true,
left: "10%",
top: "20%",
bottom: "10%",
right: "10%",
},
xAxis: {
type: 'category',
boundaryGap: false,
name: '得分率',
nameTextStyle: {
color: '#999',
fontSize: 12,
padding: [0, 0, 10, 0]
type: "category",
data: getXValue(),
axisLine: {
lineStyle: {
color: "#333",
},
data: xAxisData.value
},
axisTick: {
show: false,
},
axisLabel: {
margin: 20, //线
textStyle: {
color: "#000",
},
},
name:'题目编号'
},
yAxis: {
type: 'value',
name: '作业时长',
nameTextStyle: {
color: '#999',
fontSize: 12,
padding: [0, 0, 10, 0]
},
},
series: [
{
name: `预估时长`,
type: 'line',
smooth: true,
symbol: 'circle',
symbolSize: 10,
type: "value",
axisLine: {
show: true,
lineStyle: {
color: '#5793f3'
color: "#B5B5B5",
},
data: estimateTime.value.map(item => ({
name: item.name,
value: item.value
}))
},
name:'平均时长',
splitLine: {
lineStyle: {
// 使
color: ["#B5B5B5"],
type: "dashed",
opacity: 0.5,
},
},
axisLabel: {},
},
series: [{
data: getYValue(),
stack: "zs",
type: "bar",
barMaxWidth: "auto",
barWidth: 60,
itemStyle: {
color: {
x: 0,
y: 0,
x2: 0,
y2: 1,
type: "linear",
global: false,
colorStops: [{
offset: 0,
color: "#5EA1FF",
},
{
name: `平均用时`,
type: 'line',
smooth: true,
symbol: 'circle',
symbolSize: 10,
lineStyle: {
color: '#d14a61'
offset: 1,
color: "#90BEFF",
},
data: avaterTime.value.map(item => ({
name: item.name,
value: item.value
}))
}
]
],
},
},
},
],
};
myChart.setOption(options);
myChart.setOption(option);
}
//
const getAvaterTime = () => {
return useOverview.tableList.reduce((acc, cur) => acc + cur.finishtimelength, 0) / useOverview.tableList.length;
//
const getYValue = () => {
const arr = [...useOverview.allData[0].timeAnalyse]
const num = useOverview.allData[0].hasAnswers.length
return arr.map(item => {
return item ? (item / num).toFixed(2) : 0
})
}
const getEstimateTime = () => {
return useOverview.tableList.reduce((acc, cur) => acc + cur.timelength, 0) / useOverview.tableList.length;
//
const getXValue = () => {
return useOverview.allData.map(item => item.id)
}
watch(() => useOverview.tableList,() => {
getyAxisData()
//
nextTick(() => {
initChart();
})