|
@@ -0,0 +1,177 @@
|
|
1
|
+$(function () {
|
|
2
|
+ function initSubjectGoodEcharts(xAxis_data, series_data) {
|
|
3
|
+ var option = {
|
|
4
|
+ animation: false,
|
|
5
|
+ title: {
|
|
6
|
+ text: "人",
|
|
7
|
+ x: "left",
|
|
8
|
+ y: "top",
|
|
9
|
+ textStyle: {
|
|
10
|
+ color: "#5F6E82",
|
|
11
|
+ fontSize: $.UnitUtil.mm2px(3),
|
|
12
|
+ fontWeight: 500,
|
|
13
|
+ },
|
|
14
|
+ },
|
|
15
|
+ color: ["#5C99FF"],
|
|
16
|
+ legend: {
|
|
17
|
+ itemWidth: $.UnitUtil.mm2px(2),
|
|
18
|
+ itemHeight: $.UnitUtil.mm2px(2),
|
|
19
|
+ top: "bottom",
|
|
20
|
+ data: ["违纪人数"],
|
|
21
|
+ },
|
|
22
|
+ grid: {
|
|
23
|
+ top: $.UnitUtil.mm2px(10),
|
|
24
|
+ left: 0,
|
|
25
|
+ right: 0,
|
|
26
|
+ bottom: $.UnitUtil.mm2px(8),
|
|
27
|
+ containLabel: true,
|
|
28
|
+ },
|
|
29
|
+ xAxis: [
|
|
30
|
+ {
|
|
31
|
+ type: "category",
|
|
32
|
+ data: xAxis_data,
|
|
33
|
+ axisLabel: {
|
|
34
|
+ color: "#5F6E82", //更改坐标轴文字颜色
|
|
35
|
+ interval: 0
|
|
36
|
+ },
|
|
37
|
+ axisTick: {
|
|
38
|
+ alignWithLabel: true,
|
|
39
|
+ },
|
|
40
|
+ boundaryGap: true,
|
|
41
|
+ triggerEvent: true,
|
|
42
|
+ axisLine: {
|
|
43
|
+ show: true, //是否显示轴线
|
|
44
|
+ lineStyle: {
|
|
45
|
+ color: "#DADADA", //刻度线的颜色
|
|
46
|
+ },
|
|
47
|
+ },
|
|
48
|
+ },
|
|
49
|
+ ],
|
|
50
|
+ yAxis: [
|
|
51
|
+ {
|
|
52
|
+ type: "value",
|
|
53
|
+ axisTick: {
|
|
54
|
+ show: false, //刻度
|
|
55
|
+ },
|
|
56
|
+ axisLine: {
|
|
57
|
+ show: false, //是否显示轴线
|
|
58
|
+ lineStyle: {
|
|
59
|
+ color: "#DADADA", //刻度线的颜色
|
|
60
|
+ },
|
|
61
|
+ },
|
|
62
|
+ splitLine: {
|
|
63
|
+ //网格线
|
|
64
|
+ lineStyle: {
|
|
65
|
+ type: "dotted", //设置网格线类型 dotted:虚线 solid:实线
|
|
66
|
+ },
|
|
67
|
+ show: true, //隐藏或显示
|
|
68
|
+ },
|
|
69
|
+ axisLabel: {
|
|
70
|
+ color: "#5F6E82", //更改坐标轴文字颜色
|
|
71
|
+ },
|
|
72
|
+ },
|
|
73
|
+ ],
|
|
74
|
+ series: [
|
|
75
|
+ {
|
|
76
|
+ name: "违纪人数",
|
|
77
|
+ type: "bar",
|
|
78
|
+ barWidth: $.UnitUtil.mm2px(5),
|
|
79
|
+ // 柱状图最小高度
|
|
80
|
+ barMinHeight: $.UnitUtil.mm2px(2),
|
|
81
|
+ barGap: 0,
|
|
82
|
+ label: {
|
|
83
|
+ normal: {
|
|
84
|
+ show: true,
|
|
85
|
+ align: "center",
|
|
86
|
+ verticalAlign: "bottom",
|
|
87
|
+ position: "top",
|
|
88
|
+ distance: 0,
|
|
89
|
+ formatter: "{c}",
|
|
90
|
+ },
|
|
91
|
+ },
|
|
92
|
+ data: series_data,
|
|
93
|
+ },
|
|
94
|
+ ],
|
|
95
|
+ };
|
|
96
|
+ var myEcharts = echarts.init(document.querySelector(".section_5 #subjectGoodEcharts"));
|
|
97
|
+ myEcharts.clear();
|
|
98
|
+ myEcharts.setOption(option);
|
|
99
|
+ }
|
|
100
|
+ var parameter = $(".section_5_html_root").data("page-params");
|
|
101
|
+ parameter = JSON.parse(parameter);
|
|
102
|
+ var subjectid_subjectname = {};
|
|
103
|
+ var subjectid_num = {};
|
|
104
|
+ var classes = [];
|
|
105
|
+ parameter = $.map(parameter, function(paraItem) {
|
|
106
|
+ paraItem.subjectjson = paraItem.subjectjson ? JSON.parse(paraItem.subjectjson) : [];
|
|
107
|
+ var subjects = {};
|
|
108
|
+ var class_num = 0;
|
|
109
|
+ $.each(paraItem.subjectjson, function(index, subjectItem) {
|
|
110
|
+ subjectid_subjectname[subjectItem.subjectid] = subjectItem.subjectname;
|
|
111
|
+ if (subjectid_num[subjectItem.subjectid]) {
|
|
112
|
+ subjectid_num[subjectItem.subjectid] += subjectItem.num;
|
|
113
|
+ } else {
|
|
114
|
+ subjectid_num[subjectItem.subjectid] = subjectItem.num;
|
|
115
|
+ }
|
|
116
|
+ subjects[subjectItem.subjectid] = {
|
|
117
|
+ num: subjectItem.num,
|
|
118
|
+ nrate: subjectItem.nrate,
|
|
119
|
+ };
|
|
120
|
+ class_num += subjectItem.num;
|
|
121
|
+ });
|
|
122
|
+ classes.push({
|
|
123
|
+ classid: paraItem.classid,
|
|
124
|
+ classname: paraItem.classname,
|
|
125
|
+ class_num: class_num,
|
|
126
|
+ subjects: subjects
|
|
127
|
+ });
|
|
128
|
+ return paraItem;
|
|
129
|
+ });
|
|
130
|
+ var xAxis_data = [];
|
|
131
|
+ var series_data = [];
|
|
132
|
+ var maxSubjectInfo = {
|
|
133
|
+ num: 0,
|
|
134
|
+ subjectname: ""
|
|
135
|
+ };
|
|
136
|
+ var goodTableHeadTr1Html = '<th rowspan="2">班级</th>';
|
|
137
|
+ var goodTableHeadTr2Html = '';
|
|
138
|
+ for (var subjectid in subjectid_subjectname) {
|
|
139
|
+ xAxis_data.push(subjectid_subjectname[subjectid]);
|
|
140
|
+ series_data.push(subjectid_num[subjectid]);
|
|
141
|
+ if(maxSubjectInfo.num < subjectid_num[subjectid]) {
|
|
142
|
+ maxSubjectInfo = {
|
|
143
|
+ num: subjectid_num[subjectid],
|
|
144
|
+ subjectname: subjectid_subjectname[subjectid]
|
|
145
|
+ };
|
|
146
|
+ }
|
|
147
|
+ // class="w29mm"
|
|
148
|
+ goodTableHeadTr1Html += '<th colspan="2">' + subjectid_subjectname[subjectid] + '</th>';
|
|
149
|
+ goodTableHeadTr2Html += '<th>人数</th><th>比例</th>';
|
|
150
|
+ }
|
|
151
|
+ $(".section_5 .subjectGoodMaxNum").text(maxSubjectInfo.subjectname);
|
|
152
|
+ initSubjectGoodEcharts(xAxis_data, series_data);
|
|
153
|
+ var maxClassInfo = {
|
|
154
|
+ num: 0,
|
|
155
|
+ classname: ""
|
|
156
|
+ };
|
|
157
|
+ var goodTableTbodyHtml = "";
|
|
158
|
+ for (var i = 0; i < classes.length; i++) {
|
|
159
|
+ var classItem = classes[i];
|
|
160
|
+ var trHtml = '<td><div class="my_cell">' + classItem.classname + '</div></td>'
|
|
161
|
+ if (maxClassInfo.num < classItem.class_num) {
|
|
162
|
+ maxClassInfo = {
|
|
163
|
+ num: classItem.class_num,
|
|
164
|
+ classname: classItem.classname
|
|
165
|
+ };
|
|
166
|
+ }
|
|
167
|
+ for (var subjectid in subjectid_subjectname) {
|
|
168
|
+ series_data.push(subjectid_num[subjectid]);
|
|
169
|
+ 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>'
|
|
170
|
+ }
|
|
171
|
+ goodTableTbodyHtml += '<tr>' + trHtml + '</tr>';
|
|
172
|
+ }
|
|
173
|
+ $(".section_5 .classGoodMaxNum").text(maxClassInfo.classname);
|
|
174
|
+ $(".section_5 .goodTableHeadTr1").html(goodTableHeadTr1Html);
|
|
175
|
+ $(".section_5 .goodTableHeadTr2").html(goodTableHeadTr2Html);
|
|
176
|
+ $(".section_5 .goodTableTbody").html(goodTableTbodyHtml);
|
|
177
|
+});
|