$(function () {
function classscorePartEcharts (s_index, obj) {
var legend_data = [];
legend_data.push(obj.subjectname);
var xAxis_data = [];
var dataArr = [];
var list = $.grep(obj.ranks, function (val) {
return val.classid == 0;
});
$.each(list, function (index, item) {
xAxis_data.push(item.rankname);
dataArr.push(item.stunum);
});
var series_data = [
{
name: obj.subjectname,
type: "line",
symbol: "circle",
stack: obj.subjectname,
label: {
normal: {
show: true,
align: "center",
verticalAlign: "bottom",
position: "top",
distance: 0,
formatter: "{c}"
}
},
data: dataArr
}
];
var option = {
animation: false,
title: {
text: "人",
x: "left",
y: "top",
textStyle: {
color: "#5F6E82",
fontSize: $.UnitUtil.mm2px(3),
fontWeight: 500
}
},
color: ["#5C99FF", "#ff5f56", "#5EC5C8", "#f1982b", "#6e5eff"],
legend: {
icon: "roundRect",
itemWidth: $.UnitUtil.mm2px(2),
itemHeight: $.UnitUtil.mm2px(2),
top: "bottom",
data: legend_data
},
grid: {
top: $.UnitUtil.mm2px(10),
left: 0,
right: 0,
bottom: $.UnitUtil.mm2px(8),
containLabel: true
},
xAxis: {
type: "category",
axisLabel: {
textStyle: {
color: "#5F6E82"
},
interval: 2,
rotate: 0
},
axisTick: {
show: false
},
data: xAxis_data
},
yAxis: {
axisLabel: {
textStyle: {
color: "#9B9B9BFF"
},
interval: 0
},
minInterval: 1,
axisLine: {
show: false
},
axisTick: {
show: false
},
splitLine: {
//网格线
lineStyle: {
type: "solid", //设置网格线类型 dotted:虚线 solid:实线
color: "#DADADA"
},
show: true //隐藏或显示
},
type: "value"
},
series: series_data
};
var myEcharts = echarts.init(
$(".part_" + s_index + " #classPartEcharts")[0]
);
myEcharts.clear();
myEcharts.setOption(option);
showgraphicaldata(obj, xAxis_data, s_index);
}
function showgraphicaldata (obj, xAxis_data, s_index) {
//图表数据
var data = JSON.parse(JSON.stringify(obj));
var calsslist = [];
var tableobj = {};
var num = -1;
var rownum = 6;//一行七条数据
// if(s_index != 0) return
$.each(xAxis_data, function (idx, item) {
if ((idx + rownum) % rownum == 0) {
num++;
tableobj[num+"trHtml"] = "";
tableobj[num + "goodTableHeadTr1Html"] = '
班级 | ';
tableobj[num + "goodTableHeadTr2Html"] = "";
}
tableobj[num + "goodTableHeadTr1Html"] += '' + item + " | ";
tableobj[num+"goodTableHeadTr2Html"]+= "人数 | 比例 | ";
});
$.each(data.ranks, function (idx, item) {
if ($.inArray(item.classname, calsslist) == -1) {
calsslist.push(item.classname);
}
})
$.each(calsslist, function (index, items) {
var num = -1;
var classs = $.grep(data.ranks, function (val) {
return val.classname == items;
});
$.each(xAxis_data, function (idx, item) {
var rank = $.grep(classs, function (val) {
return val.rankname == item;
})[0];
if ((idx + rownum) % rownum == 0) {
num++;
if (index == 0) {
tableobj[num + "trHtml"] += "";
} else {
tableobj[num + "trHtml"] += "
";
}
tableobj[num+"trHtml"] += '' + items + " | ";
}
tableobj[num+"trHtml"] +=
'' +
rank.stunum +
' | ' +
rank.sturate +
"% | ";
});
})
//计算表格高度 页面高1047 剩余高度700 表头62.5 内容27.42
var tableheight = (calsslist.length * 27.5+62.5 +15) * (num+1);
var page = {
1:"",2:"",3:""
}; //页数
var table = "";
var itemheight = calsslist.length * 27.5 + 62.5 + 15; //单表高度
var maxheight = 0;
for (var i = 0; i < num + 1; i++){
maxheight = itemheight * (i + 1)
var content = ' ' +
tableobj[i + "goodTableHeadTr1Html"] + '
' +
tableobj[i + "goodTableHeadTr2Html"] + '
' +
tableobj[i + "trHtml"] + '
';
//计算剩余高度是否能显示最后一个表格
if (maxheight > 700 || 700-maxheight 1747 || 1747-maxheight 700) {
//添加第一页
$(".part_" + s_index).after('')
$(".part_" + s_index + "_1").html(page[1]);
} else if (tableheight > 1747) {
//添加第二页
$(".part_" + s_index+'_1').after('')
$(".part_" + s_index + "_2").html(page[2]);
}
}
var parameter = $(".section_2_html_root .section_2_part_html_root").data(
"page-params"
);
parameter = JSON.parse(parameter);
// console.log(parameter);
var subjectInfo = [];
for (var sid in parameter) {
if (sid === "zf") {
subjectInfo.unshift({
subjectid: sid,
subjectname: "全部年级",
ranks: parameter[sid].ranks,
maxscore: parameter[sid].maxscore
});
} else {
subjectInfo.push({
subjectid: sid,
subjectname: parameter[sid].subjectname,
ranks: parameter[sid].ranks,
maxscore: parameter[sid].maxscore
});
}
}
var singleRootHtml = "";
$.each(subjectInfo, function (s_index, s_item) {
singleRootHtml +=
'' +
(s_index === 0 ? '
3.分数分段对比
' : "") +
'
3.' +
(s_index + 1) +
" " +
s_item.subjectname +
'分数段统计
3.' +
(s_index + 1) +
'.1 各分数段分析
当前设置分数段:10分/段
3.' +
(s_index + 1) +
'.2 各班等级比例分布
';
});
$(".section_2_part_root").html(singleRootHtml);
$.each(subjectInfo, function (s_index, s_item) {
$(".part_ " + s_index + " .curscorepart").text(s_item.maxscore);
classscorePartEcharts(s_index, s_item);
// var height = $(".part_" + s_index).height()
})
});