123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232 |
- $(function () {
- function initgoodexamEcharts(list) {
- var itemStyle = {
- normal: {
- label: {
- show: true, //开启显示数值
- position: "top" //数值在上方显示
- }
- }
- };
- var num = [],
- xAxis_data = [];
- var curlegend = ["优秀人数"];
- var curclass = {
- num: 0,
- classname: ""
- };
- $.each(list.yxsjkm, 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_5 .subjectgoodexamMaxNum").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_5 #goodexamEcharts")[0]);
- myEcharts.clear();
- myEcharts.setOption(option);
- showgoodexamable(list);
- }
-
- function showgoodexamable(list) {
- var table = {},
- goodTableHeadTr1Html =
- '<th colspan="2">考试信息</th><th colspan="' +
- list.yxsjkm.length +
- '">科目信息</th>',
- goodTableHeadTr2Html = "<th>姓名</th><th>账号</th>",
- trHtml = "";
- var surplusheight = pageheight - $(".section_5 .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.yxsjkm, function (idx, item) {
- goodTableHeadTr2Html += "<th>" + item.subjectname + "</th>";
- });
- $.each(list.yxsj, 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] +=
- "<tr><td>" + item.username + "</td><td>" + item.loginname + "</td>";
- 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] += "<td>" + (subject_num[item.subjectid] || 0) + "</td>";
- });
- });
- //高度 89
- var isadd = true;
- var maxstuhtml =
- '<div class="echarts_result"><div>上图统计结果表示:</div><div class="echarts_result_content"><span class="dot bg_5699FF"></span>优秀试卷最多的学生:' +
- maxstu.username +
- "</div></div>";
- for (var i = 0; i <= page; i++) {
- table[i] =
- '<table border="1" class="my_table"><thead><tr class="goodTableHeadTr1">' +
- goodTableHeadTr1Html +
- '</tr><tr class="goodTableHeadTr2">' +
- goodTableHeadTr2Html +
- '</tr></thead><tbody class="goodTableTbody">' +
- pagedaba[i] +
- "</tbody></table>";
- if (i != 0) {
- //添加分页
- $(".page_" + (i - 1) + ".section_5").after(
- '<div class="page_root section_5' + " page_" + i + '"></div>'
- );
- $(".page_root.section_5" + ".page_" + i).html(table[i]);
- }
- //添加表格结果数据
- if (i == 0 && surplusheight - pagesheight[i] >= 89) {
- isadd = false;
- $(".section_5 .stugoodexamtable").after(
- '<div class="echarts_result resultdata"></div>'
- );
- $(".echarts_result.resultdata").html(maxstuhtml);
- } else if (i != 0 && pageheight - pagesheight[i] >= 89) {
- isadd = false;
- $(".page_" + i + ".section_5 .my_table").after(
- '<div class="page_' + (i + 1) + ' my_result"></div>'
- );
- $(".page_" + (i + 1) + ".my_result").html(maxstuhtml);
- }
- }
- $(".section_5 .stugoodexamtable").html(table[0]);
- //添加至新页
- if (isadd) {
- $(".page_" + page).after(
- '<div class="page_root section_5 page_' + (page + 1) + '"></div>'
- );
- $(".page_" + (page + 1) + "").html(maxstuhtml);
- }
- }
-
- var parameter = $(".section_5_html_root").data("page-params");
- parameter = JSON.parse(parameter);
- initgoodexamEcharts(parameter);
- });
|