You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

section_2_level.js 11KB

1 year ago
1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. $(function () {
  2. //各班等级分析
  3. function initclassLevelEcharts(s_index, list) {
  4. var xAxis_data = [],
  5. series_data = [],
  6. legend_data = [],
  7. levelRateObj = {},
  8. levelNumObj = {},
  9. levelrangeObj = [];
  10. $.each(list, function (key, item) {
  11. if ($.inArray(item.classname, xAxis_data) == -1) {
  12. xAxis_data.push(item.classname);
  13. }
  14. if ($.inArray(item.rankname + "类", legend_data) == -1) {
  15. legend_data.push(item.rankname + "类");
  16. }
  17. if ($.inArray(item.rankrange, levelrangeObj) == -1) {
  18. levelrangeObj.push(item.rankrange);
  19. }
  20. if (!levelRateObj[item.rankname + "类"]) {
  21. levelRateObj[item.rankname + "类"] = [];
  22. }
  23. levelRateObj[item.rankname + "类"].push(item.sturate);
  24. if (!levelNumObj[item.rankname + "类"]) {
  25. levelNumObj[item.rankname + "类"] = [];
  26. }
  27. levelNumObj[item.rankname + "类"].push(item.stunum);
  28. });
  29. $.each(legend_data, function (key, item) {
  30. series_data.push({
  31. name: item,
  32. type: "bar",
  33. stack: "总量",
  34. barWidth: 32,
  35. // 柱状图最小高度
  36. barMinHeight: 16,
  37. showBackground: true, // 柱状图显示背景
  38. backgroundStyle: {
  39. color: "#F3F4F5"
  40. },
  41. itemStyle: {
  42. normal: {
  43. barBorderRadius: [4, 4, 4, 4]
  44. }
  45. },
  46. label: {
  47. normal: {
  48. show: true,
  49. align: "center",
  50. verticalAlign: "middle",
  51. position: "inside",
  52. distance: 0,
  53. color: "#fff",
  54. formatter: function (params) {
  55. return levelNumObj[params.seriesName][params.dataIndex] || 0;
  56. }
  57. }
  58. },
  59. data: levelNumObj[item]
  60. });
  61. });
  62. showgraphicaldata(xAxis_data, legend_data, levelrangeObj, s_index, list);
  63. var option = {
  64. color: ["#5C99FF", "#ff5f56", "#5EC5C8", "#f1982b", "#6e5eff"],
  65. animation: false,
  66. title: {
  67. text: "%",
  68. x: "left",
  69. y: "top",
  70. textStyle: {
  71. color: "#5F6E82",
  72. fontSize: $.UnitUtil.mm2px(3),
  73. fontWeight: 500
  74. }
  75. },
  76. legend: {
  77. itemWidth: $.UnitUtil.mm2px(2),
  78. itemHeight: $.UnitUtil.mm2px(2),
  79. top: "bottom",
  80. data: legend_data
  81. },
  82. grid: {
  83. top: $.UnitUtil.mm2px(10),
  84. left: 0,
  85. right: 0,
  86. bottom: $.UnitUtil.mm2px(8),
  87. containLabel: true
  88. },
  89. xAxis: [
  90. {
  91. type: "category",
  92. data: xAxis_data,
  93. axisLabel: {
  94. color: "#5F6E82", //更改坐标轴文字颜色
  95. interval: 0
  96. },
  97. axisTick: {
  98. alignWithLabel: true
  99. },
  100. boundaryGap: true,
  101. triggerEvent: true,
  102. axisLine: {
  103. show: true, //是否显示轴线
  104. lineStyle: {
  105. color: "#DADADA" //刻度线的颜色
  106. }
  107. }
  108. }
  109. ],
  110. yAxis: [
  111. {
  112. type: "value",
  113. axisTick: {
  114. show: false //刻度
  115. },
  116. axisLine: {
  117. show: false, //是否显示轴线
  118. lineStyle: {
  119. color: "#DADADA" //刻度线的颜色
  120. }
  121. },
  122. splitLine: {
  123. //网格线
  124. lineStyle: {
  125. type: "dotted" //设置网格线类型 dotted:虚线 solid:实线
  126. },
  127. show: true //隐藏或显示
  128. },
  129. axisLabel: {
  130. color: "#5F6E82" //更改坐标轴文字颜色
  131. }
  132. }
  133. ],
  134. series: series_data
  135. };
  136. var myEcharts = echarts.init(
  137. $(
  138. ".section_2_level.level_" + s_index + " #classLevelEcharts"
  139. )[0]
  140. );
  141. myEcharts.clear();
  142. myEcharts.setOption(option);
  143. }
  144. //图表数据
  145. function showgraphicaldata(
  146. xAxis_data,
  147. legend_data,
  148. levelrangeObj,
  149. s_index,
  150. list
  151. ) {
  152. //图表数据
  153. var arr = JSON.parse(JSON.stringify(list));
  154. var goodTableHeadTr1Html = '<th rowspan="2">班级</th>';
  155. var goodTableHeadTr2Html = "";
  156. var goodTableTbodyHtml = "";
  157. $.each(legend_data, function (idx, item) {
  158. goodTableHeadTr1Html +=
  159. '<th colspan="2">' + item + levelrangeObj[idx] + "</th>";
  160. goodTableHeadTr2Html += "<th>人数</th><th>比例</th>";
  161. });
  162. $.each(xAxis_data, function (idx, item) {
  163. var trHtml = '<td><div class="my_cell">' + item + "</div></td>";
  164. var classs = $.grep(arr, function (val) {
  165. return val.classname == item;
  166. });
  167. $.each(legend_data, function (idx, item) {
  168. var rank = $.grep(classs, function (val) {
  169. return val.rankname + "类" == item;
  170. })[0];
  171. trHtml +=
  172. '<td><div class="my_cell">' +
  173. rank.stunum +
  174. '</div></td><td><div class="my_cell">' +
  175. rank.sturate +
  176. "%</div></td>";
  177. });
  178. goodTableTbodyHtml += "<tr>" + trHtml + "</tr>";
  179. });
  180. $(".section_2_level.level_" + s_index + " .goodTableHeadTr1").html(
  181. goodTableHeadTr1Html
  182. );
  183. $(".section_2_level.level_" + s_index + " .goodTableHeadTr2").html(
  184. goodTableHeadTr2Html
  185. );
  186. $(".section_2_level.level_" + s_index + " .goodTableTbody").html(
  187. goodTableTbodyHtml
  188. );
  189. var totalObj = {};
  190. var maxObj = {};
  191. var minObj = {};
  192. var classObj = {};
  193. $.each(list, function (index, listItem) {
  194. if (!totalObj[listItem.rankname]) {
  195. totalObj[listItem.rankname] = {};
  196. }
  197. if (!maxObj[listItem.rankname]) {
  198. maxObj[listItem.rankname] = {
  199. stunum: 0,
  200. classidArr: []
  201. };
  202. }
  203. if (listItem.classid === 0) {
  204. totalObj[listItem.rankname].stunum = listItem.stunum;
  205. totalObj[listItem.rankname].sturate = listItem.sturate;
  206. } else {
  207. classObj[listItem.classid] = listItem.classname;
  208. if (maxObj[listItem.rankname].stunum < listItem.stunum) {
  209. maxObj[listItem.rankname].stunum = listItem.stunum;
  210. maxObj[listItem.rankname].classidArr = [listItem.classid];
  211. } else if (maxObj[listItem.rankname].stunum === listItem.stunum) {
  212. maxObj[listItem.rankname].classidArr.push(listItem.classid);
  213. }
  214. }
  215. });
  216. $.each(list, function (index, listItem) {
  217. if (!minObj[listItem.rankname]) {
  218. minObj[listItem.rankname] = {
  219. stunum: maxObj[listItem.rankname].stunum,
  220. classidArr: []
  221. };
  222. }
  223. if (listItem.classid !== 0) {
  224. if (minObj[listItem.rankname].stunum > listItem.stunum) {
  225. minObj[listItem.rankname].stunum = listItem.stunum;
  226. minObj[listItem.rankname].classidArr = [listItem.classid];
  227. } else if (minObj[listItem.rankname].stunum === listItem.stunum) {
  228. minObj[listItem.rankname].classidArr.push(listItem.classid);
  229. }
  230. }
  231. });
  232. $(".section_2_level.level_" + s_index + " .result_collect").text(
  233. "A类" +
  234. totalObj["A"].stunum +
  235. "人(" +
  236. totalObj["A"].sturate +
  237. "%),B类" +
  238. totalObj["B"].stunum +
  239. "人(" +
  240. totalObj["B"].sturate +
  241. "%),C类" +
  242. totalObj["C"].stunum +
  243. "人(" +
  244. totalObj["C"].sturate +
  245. "%),D类" +
  246. totalObj["D"].stunum +
  247. "人(" +
  248. totalObj["D"].sturate +
  249. "%),E类" +
  250. totalObj["E"].stunum +
  251. "人(" +
  252. totalObj["E"].sturate +
  253. "%)"
  254. );
  255. $(".section_2_level.level_" + s_index + " .A_collect").text(
  256. "A类上线率最高的班级:" +
  257. $.map(maxObj["A"].classidArr, function (classid) {
  258. return classObj[classid];
  259. }).join("、") +
  260. ",A类上线率最低的班级:" +
  261. $.map(minObj["A"].classidArr, function (classid) {
  262. return classObj[classid];
  263. }).join("、")
  264. );
  265. $(".section_2_level.level_" + s_index + " .B_collect").text(
  266. "B类上线率最高的班级:" +
  267. $.map(maxObj["B"].classidArr, function (classid) {
  268. return classObj[classid];
  269. }).join("、") +
  270. ",B类上线率最低的班级:" +
  271. $.map(minObj["B"].classidArr, function (classid) {
  272. return classObj[classid];
  273. }).join("、")
  274. );
  275. $(".section_2_level.level_" + s_index + " .C_collect").text(
  276. "C类上线率最高的班级:" +
  277. $.map(maxObj["C"].classidArr, function (classid) {
  278. return classObj[classid];
  279. }).join("、") +
  280. ",C类上线率最低的班级:" +
  281. $.map(minObj["C"].classidArr, function (classid) {
  282. return classObj[classid];
  283. }).join("、")
  284. );
  285. $(".section_2_level.level_" + s_index + " .D_collect").text(
  286. "D类上线率最高的班级:" +
  287. $.map(maxObj["D"].classidArr, function (classid) {
  288. return classObj[classid];
  289. }).join("、") +
  290. ",D类上线率最低的班级:" +
  291. $.map(minObj["D"].classidArr, function (classid) {
  292. return classObj[classid];
  293. }).join("、")
  294. );
  295. $(".section_2_level.level_" + s_index + " .E_collect").text(
  296. "E类上线率最高的班级:" +
  297. $.map(maxObj["E"].classidArr, function (classid) {
  298. return classObj[classid];
  299. }).join("、") +
  300. ",E类上线率最低的班级:" +
  301. $.map(minObj["E"].classidArr, function (classid) {
  302. return classObj[classid];
  303. }).join("、")
  304. );
  305. }
  306. var parameter = $(".section_2_html_root .section_2_level_html_root").data(
  307. "page-params"
  308. );
  309. parameter = JSON.parse(parameter);
  310. // console.log(parameter);
  311. var subjectInfo = [];
  312. for (var sid in parameter) {
  313. if (sid === "zf") {
  314. subjectInfo.unshift({
  315. subjectid: sid,
  316. subjectname: "全科",
  317. ranks: parameter[sid].ranks
  318. });
  319. } else {
  320. subjectInfo.push({
  321. subjectid: sid,
  322. subjectname: parameter[sid].subjectname,
  323. ranks: parameter[sid].ranks
  324. });
  325. }
  326. }
  327. var singleRootHtml = "";
  328. $.each(subjectInfo, function (s_index, s_item) {
  329. singleRootHtml +=
  330. '<div class="page_root section_2_level level_' +
  331. s_index +
  332. '">' +
  333. (s_index === 0 ? '<h2 class="section_title_2">2.分数等级对比</h2>' : "") +
  334. '<h3 class="section_title_3">2.' +
  335. (s_index + 1) +
  336. " " +
  337. s_item.subjectname +
  338. '等级对比</h3><h4 class="section_title_4">2.' +
  339. (s_index + 1) +
  340. '.1 各班等级分析</h4><div id="classLevelEcharts" style="margin: 0 4mm 4mm; height: 80mm"></div><h4 class="section_title_4">2.' +
  341. (s_index + 1) +
  342. '.2 各班等级比例分布</h4><table border="1" class="my_table"><thead><tr class="goodTableHeadTr1"></tr><tr class="goodTableHeadTr2"></tr></thead><tbody class="goodTableTbody"></tbody></table><div class="echarts_result"><div>上图各等级上线统计结果为:<span class="result_collect"></span>:</div><div class="echarts_result_content"><div><span class="bg_5699FF"></span><i class="A_collect"></i></div><div><span class="bg_FF5F56"></span><i class="B_collect"></i></div><div><span class="bg_5EC5C8"></span><i class="C_collect"></i></div><div><span class="bg_F1982B"></span><i class="D_collect"></i></div><div><span class="bg_F1982B"></span><i class="E_collect"></i></div></div></div></div>';
  343. });
  344. $(".section_2_level_root").html(singleRootHtml);
  345. $.each(subjectInfo, function (s_index, s_item) {
  346. initclassLevelEcharts(s_index, s_item.ranks);
  347. });
  348. });