123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- $(function () {
- function initSubjectBadEcharts(xAxis_data, series_data) {
- var option = {
- animation: false,
- title: {
- text: "人",
- x: "left",
- y: "top",
- textStyle: {
- color: "#5F6E82",
- fontSize: $.UnitUtil.mm2px(3),
- fontWeight: 500,
- },
- },
- color: ["#5C99FF"],
- legend: {
- itemWidth: $.UnitUtil.mm2px(2),
- itemHeight: $.UnitUtil.mm2px(2),
- top: "bottom",
- data: ["违纪人数"],
- },
- grid: {
- top: $.UnitUtil.mm2px(10),
- left: 0,
- right: 0,
- bottom: $.UnitUtil.mm2px(8),
- containLabel: true,
- },
- xAxis: [
- {
- type: "category",
- data: xAxis_data,
- axisLabel: {
- color: "#5F6E82", //更改坐标轴文字颜色
- interval: 0
- },
- 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: [
- {
- name: "违纪人数",
- type: "bar",
- barWidth: $.UnitUtil.mm2px(5),
- // 柱状图最小高度
- barMinHeight: $.UnitUtil.mm2px(2),
- barGap: 0,
- label: {
- normal: {
- show: true,
- align: "center",
- verticalAlign: "bottom",
- position: "top",
- distance: 0,
- formatter: "{c}",
- },
- },
- data: series_data,
- },
- ],
- };
- var myEcharts = echarts.init($(".section_3 #subjectBadEcharts")[0]);
- myEcharts.clear();
- myEcharts.setOption(option);
- }
- var parameter = $(".section_3_html_root").data("page-params");
- parameter = JSON.parse(parameter);
- var subjectid_subjectname = {};
- var subjectid_num = {};
- var classes = [];
- parameter = $.map(parameter, function(paraItem) {
- paraItem.subjectjson = paraItem.subjectjson ? JSON.parse(paraItem.subjectjson) : [];
- var subjects = {};
- var class_num = 0;
- $.each(paraItem.subjectjson, function(index, subjectItem) {
- subjectid_subjectname[subjectItem.subjectid] = subjectItem.subjectname;
- if (subjectid_num[subjectItem.subjectid]) {
- subjectid_num[subjectItem.subjectid] += subjectItem.num;
- } else {
- subjectid_num[subjectItem.subjectid] = subjectItem.num;
- }
- subjects[subjectItem.subjectid] = {
- num: subjectItem.num,
- nrate: subjectItem.nrate,
- };
- class_num += subjectItem.num;
- });
- classes.push({
- classid: paraItem.classid,
- classname: paraItem.classname,
- class_num: class_num,
- subjects: subjects
- });
- return paraItem;
- });
- var xAxis_data = [];
- var series_data = [];
- var maxSubjectInfo = {
- num: 0,
- subjectname: ""
- };
- var badTableHeadTr1Html = '<th rowspan="2">班级</th>';
- var badTableHeadTr2Html = '';
- for (var subjectid in subjectid_subjectname) {
- xAxis_data.push(subjectid_subjectname[subjectid]);
- series_data.push(subjectid_num[subjectid]);
- if(maxSubjectInfo.num < subjectid_num[subjectid]) {
- maxSubjectInfo = {
- num: subjectid_num[subjectid],
- subjectname: subjectid_subjectname[subjectid]
- };
- }
- // class="w29mm"
- badTableHeadTr1Html += '<th colspan="2">' + subjectid_subjectname[subjectid] + '</th>';
- badTableHeadTr2Html += '<th>人数</th><th>比例</th>';
- }
- $(".section_3 .subjectBadMaxNum").text(maxSubjectInfo.subjectname);
- initSubjectBadEcharts(xAxis_data, series_data);
- var maxClassInfo = {
- num: 0,
- classname: ""
- };
- var badTableTbodyHtml = "";
- for (var i = 0; i < classes.length; i++) {
- var classItem = classes[i];
- var trHtml = '<td><div class="my_cell">' + classItem.classname + '</div></td>'
- if (maxClassInfo.num < classItem.class_num) {
- maxClassInfo = {
- num: classItem.class_num,
- classname: classItem.classname
- };
- }
- for (var subjectid in subjectid_subjectname) {
- series_data.push(subjectid_num[subjectid]);
- trHtml += '<td><div class="my_cell">' + (classItem.subjects[subjectid].num || 0) + '</div></td><td><div class="my_cell">' + (classItem.subjects[subjectid].nrate || 0) + '%</div></td>'
- }
- badTableTbodyHtml += '<tr>' + trHtml + '</tr>';
- }
- $(".section_3 .classBadMaxNum").text(maxClassInfo.classname);
- $(".section_3 .badTableHeadTr1").html(badTableHeadTr1Html);
- $(".section_3 .badTableHeadTr2").html(badTableHeadTr2Html);
- $(".section_3 .badTableTbody").html(badTableTbodyHtml);
- });
|