$(function () {
function initviolationEcharts(list) {
var itemStyle = {
normal: {
label: {
show: true, //开启显示数值
position: "top" //数值在上方显示
}
}
};
var num = [],
xAxis_data = [];
var curlegend = ["违纪人数"];
var curclass = {
num: 0,
classname: ""
};
$.each(list.wjkm, function (idx, item) {
if (item.num > curclass.num) {
curclass = {
num: item.num,
classname: item.subjectname
};
}
num.push(item.num);
xAxis_data.push(item.subjectname);
});
$(".section_4 .subjectviolationMaxNum").text(curclass.classname);
var curseries = [
{
name: "违纪人数",
type: "bar",
barWidth: $.UnitUtil.mm2px(5),
// 柱状图最小高度
barMinHeight: $.UnitUtil.mm2px(2),
barGap: 0,
data: num,
itemStyle: itemStyle
}
];
var option = {
animation: false,
color: ["#5C99FF", "#FF5F56", "#5EC5C8", "#f1982b"],
title: {
text: "人",
x: "left",
y: "top",
textStyle: {
color: "#5F6E82",
fontSize: $.UnitUtil.mm2px(3),
fontWeight: 500
}
},
legend: {
itemWidth: $.UnitUtil.mm2px(2),
itemHeight: $.UnitUtil.mm2px(2),
top: "bottom",
data: curlegend
},
grid: {
top: $.UnitUtil.mm2px(10),
left: 0,
right: 0,
bottom: $.UnitUtil.mm2px(8),
containLabel: true
},
xAxis: [
{
type: "category",
data: xAxis_data,
axisLabel: {
color: "#5F6E82" //更改坐标轴文字颜色
},
axisTick: {
alignWithLabel: true
},
boundaryGap: true,
triggerEvent: true,
axisLine: {
show: true, //是否显示轴线
lineStyle: {
color: "#DADADA" //刻度线的颜色
}
}
}
],
yAxis: [
{
type: "value",
axisTick: {
show: false //刻度
},
axisLine: {
show: false, //是否显示轴线
lineStyle: {
color: "#DADADA" //刻度线的颜色
}
},
splitLine: {
//网格线
lineStyle: {
type: "dotted" //设置网格线类型 dotted:虚线 solid:实线
},
show: true //隐藏或显示
},
axisLabel: {
color: "#5F6E82" //更改坐标轴文字颜色
}
}
],
series: curseries
};
var myEcharts = echarts.init($(".section_4 #violationEcharts")[0]);
myEcharts.clear();
myEcharts.setOption(option);
showviolationtable(list);
}
function showviolationtable(list) {
var table = {},
goodTableHeadTr1Html =
'
考试信息 | 科目信息 | ',
goodTableHeadTr2Html = "姓名 | 账号 | ",
trHtml = "";
var surplusheight = pageheight - $(".section_4 .violationheight").height(); //本页剩余高度
var henght = 62.46,
row = 27.42; //表头62.46 一行高27.42
var pagedaba = {
0: ""
},
page = 0;
var maxstu = {
num: 0,
username: ""
};
var pagesheight = {
0: 0
};
$.each(list.wjkm, function (idx, item) {
goodTableHeadTr2Html += "" + item.subjectname + " | ";
});
$.each(list.wjfx, function (idx, item) {
if (
page == 0 &&
(henght >= surplusheight || surplusheight - henght <= row)
) {
// 加第一页
page++;
henght = 62.46;
pagedaba[page] = "";
}
if (page != 0 && (henght >= pageheight || pageheight - henght <= row)) {
page++;
henght = 62.46;
pagedaba[page] = "";
}
henght += row;
pagesheight[page] = henght;
item.subjectjson = item.subjectjson ? JSON.parse(item.subjectjson) : [];
var subject_num = {};
pagedaba[page] +=
"" + item.username + " | " + item.loginname + " | ";
var num = 0;
$.each(item.subjectjson, function (idx, item) {
num += item.num;
subject_num[item.subjectid] = item.num || 0;
});
if (num > maxstu.num) {
maxstu = {
num: num,
username: item.username
};
} else if (num == maxstu.num) {
maxstu.username += "、" + item.username;
}
$.each(list.wjkm, function (idx, item) {
pagedaba[page] += "" + (subject_num[item.subjectid] || 0) + " | ";
});
});
//高度 89
var isadd = true;
var maxstuhtml =
'上图统计结果表示:
违纪行为最多的学生:' +
maxstu.username +
"
";
for (var i = 0; i <= page; i++) {
table[i] =
'' +
goodTableHeadTr1Html +
'
' +
goodTableHeadTr2Html +
'
' +
pagedaba[i] +
"
";
if (i != 0) {
//添加分页
$(".page_" + (i - 1) + ".section_4").after(
''
);
$(".page_root.section_4" + ".page_" + i).html(table[i]);
}
//添加表格结果数据
if (i == 0 && surplusheight - pagesheight[i] >= 89) {
isadd = false;
$(".section_4 .stuViolationtable").after(
''
);
$(".echarts_result.resultdata").html(maxstuhtml);
} else if (i != 0 && pageheight - pagesheight[i] >= 89) {
isadd = false;
$(".page_" + i + ".section_4 .my_table").after(
''
);
$(".page_" + (i + 1) + ".my_result").html(maxstuhtml);
}
}
$(".section_4 .stuViolationtable").html(table[0]);
//添加至新页
if (isadd) {
$(".page_" + page).after(
''
);
$(".page_" + (page + 1) + "").html(maxstuhtml);
}
}
var parameter = $(".section_4_html_root").data("page-params");
parameter = JSON.parse(parameter);
initviolationEcharts(parameter);
});