|
|
|
@ -502,29 +502,56 @@ export default { |
|
|
|
|
getChart () { // 初始化折线图 |
|
|
|
|
const xData = Array.from({ length: 101 }, (v, k) => k) |
|
|
|
|
const yData = Array.from({ length: 101 }, (v, k) => 0) |
|
|
|
|
const data = {} |
|
|
|
|
const list = this.listDataAll |
|
|
|
|
list.map(n => { |
|
|
|
|
if (!data[n.score]) { |
|
|
|
|
data[n.score] = 1 |
|
|
|
|
} else { |
|
|
|
|
data[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")); |
|
|
|
|
myChart.setOption({ |
|
|
|
|
title: { text: "实验分数分布图" }, |
|
|
|
|
tooltip: {}, |
|
|
|
|
xAxis: { |
|
|
|
|
name: "分数", |
|
|
|
|
type: "category", |
|
|
|
|
name: this.permissions ? "人数" : '成绩报告数量', |
|
|
|
|
type: "value", |
|
|
|
|
boundaryGap: false, |
|
|
|
|
interval: 5, |
|
|
|
|
axisLabel: { |
|
|
|
|
interval: 9, |
|
|
|
|
interval: 5 |
|
|
|
|
}, |
|
|
|
|
data: xData |
|
|
|
|
}, |
|
|
|
|
yAxis: { |
|
|
|
|
name: this.permissions ? "人数" : '成绩报告数量', |
|
|
|
|
type: "value", |
|
|
|
|
interval: 5 |
|
|
|
|
name: "分数", |
|
|
|
|
type: "category", |
|
|
|
|
min: 0, |
|
|
|
|
max: 100, |
|
|
|
|
interval: 5, |
|
|
|
|
axisLabel: { |
|
|
|
|
interval: 9 |
|
|
|
|
}, |
|
|
|
|
data: xData |
|
|
|
|
}, |
|
|
|
|
series: [{ |
|
|
|
|
data: yData, |
|
|
|
|