|
|
@ -502,29 +502,56 @@ export default { |
|
|
|
getChart () { // 初始化折线图 |
|
|
|
getChart () { // 初始化折线图 |
|
|
|
const xData = Array.from({ length: 101 }, (v, k) => k) |
|
|
|
const xData = Array.from({ length: 101 }, (v, k) => k) |
|
|
|
const yData = Array.from({ length: 101 }, (v, k) => 0) |
|
|
|
const yData = Array.from({ length: 101 }, (v, k) => 0) |
|
|
|
|
|
|
|
const data = {} |
|
|
|
const list = this.listDataAll |
|
|
|
const list = this.listDataAll |
|
|
|
list.map(n => { |
|
|
|
list.map(n => { |
|
|
|
|
|
|
|
if (!data[n.score]) { |
|
|
|
|
|
|
|
data[n.score] = 1 |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
data[n.score]++ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
yData[n.score]++ |
|
|
|
yData[n.score]++ |
|
|
|
}) |
|
|
|
}) |
|
|
|
console.log(333, xData, yData) |
|
|
|
let max = Math.max(...Object.values(data)) |
|
|
|
|
|
|
|
console.log("🚀 ~ file: project.vue:517 ~ getChart ~ max:", yData) |
|
|
|
|
|
|
|
const x = Array.from({ length: max }, (v, k) => k) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i <= max; i++) { |
|
|
|
|
|
|
|
const item = yData.findIndex(e => e == i) |
|
|
|
|
|
|
|
console.log("🚀 ~ file: project.vue:521 ~ getChart ~ item:", item) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xData.map(e => { |
|
|
|
|
|
|
|
for (let i = 0; i <= max; i++) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
// console.log(333, xData, yData, data) |
|
|
|
let myChart = echarts.init(document.getElementById("chart")); |
|
|
|
let myChart = echarts.init(document.getElementById("chart")); |
|
|
|
myChart.setOption({ |
|
|
|
myChart.setOption({ |
|
|
|
title: { text: "实验分数分布图" }, |
|
|
|
title: { text: "实验分数分布图" }, |
|
|
|
tooltip: {}, |
|
|
|
tooltip: {}, |
|
|
|
xAxis: { |
|
|
|
xAxis: { |
|
|
|
name: "分数", |
|
|
|
name: this.permissions ? "人数" : '成绩报告数量', |
|
|
|
type: "category", |
|
|
|
type: "value", |
|
|
|
boundaryGap: false, |
|
|
|
boundaryGap: false, |
|
|
|
interval: 5, |
|
|
|
interval: 5, |
|
|
|
axisLabel: { |
|
|
|
axisLabel: { |
|
|
|
interval: 9, |
|
|
|
interval: 5 |
|
|
|
}, |
|
|
|
}, |
|
|
|
data: xData |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
yAxis: { |
|
|
|
yAxis: { |
|
|
|
name: this.permissions ? "人数" : '成绩报告数量', |
|
|
|
name: "分数", |
|
|
|
type: "value", |
|
|
|
type: "category", |
|
|
|
interval: 5 |
|
|
|
min: 0, |
|
|
|
|
|
|
|
max: 100, |
|
|
|
|
|
|
|
interval: 5, |
|
|
|
|
|
|
|
axisLabel: { |
|
|
|
|
|
|
|
interval: 9 |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
data: xData |
|
|
|
}, |
|
|
|
}, |
|
|
|
series: [{ |
|
|
|
series: [{ |
|
|
|
data: yData, |
|
|
|
data: yData, |
|
|
|