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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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(
  28. item.stunum
  29. );
  30. });
  31. $.each(legend_data, function (key, item) {
  32. series_data.push({
  33. name: item,
  34. type: "bar",
  35. stack: "总量",
  36. barWidth: 32,
  37. // 柱状图最小高度
  38. barMinHeight: 16,
  39. showBackground: true, // 柱状图显示背景
  40. backgroundStyle: {
  41. color: "#F3F4F5"
  42. },
  43. itemStyle: {
  44. normal: {
  45. barBorderRadius: [4, 4, 4, 4]
  46. }
  47. },
  48. label: {
  49. normal: {
  50. show: true,
  51. align: "center",
  52. verticalAlign: "middle",
  53. position: "inside",
  54. distance: 0,
  55. color: "#fff",
  56. formatter: function (params) {
  57. return levelNumObj[params.seriesName][params.dataIndex] || 0;
  58. }
  59. }
  60. },
  61. data: levelNumObj[item]
  62. });
  63. });
  64. showgraphicaldata(xAxis_data, legend_data, levelrangeObj, s_index, list);
  65. var option = {
  66. color: ["#5C99FF", "#ff5f56", "#5EC5C8", "#f1982b", "#6e5eff"],
  67. animation: false,
  68. title: {
  69. text: "%",
  70. x: "left",
  71. y: "top",
  72. textStyle: {
  73. color: "#5F6E82",
  74. fontSize: $.UnitUtil.mm2px(3),
  75. fontWeight: 500,
  76. },
  77. },
  78. legend: {
  79. itemWidth: $.UnitUtil.mm2px(2),
  80. itemHeight: $.UnitUtil.mm2px(2),
  81. top: "bottom",
  82. data: legend_data,
  83. },
  84. grid: {
  85. top: $.UnitUtil.mm2px(10),
  86. left: 0,
  87. right: 0,
  88. bottom: $.UnitUtil.mm2px(8),
  89. containLabel: true,
  90. },
  91. xAxis: [{
  92. type: "category",
  93. data: xAxis_data,
  94. axisLabel: {
  95. color: "#5F6E82", //更改坐标轴文字颜色
  96. interval: 0
  97. },
  98. axisTick: {
  99. alignWithLabel: true,
  100. },
  101. boundaryGap: true,
  102. triggerEvent: true,
  103. axisLine: {
  104. show: true, //是否显示轴线
  105. lineStyle: {
  106. color: "#DADADA", //刻度线的颜色
  107. },
  108. },
  109. }, ],
  110. yAxis: [{
  111. type: "value",
  112. axisTick: {
  113. show: false, //刻度
  114. },
  115. axisLine: {
  116. show: false, //是否显示轴线
  117. lineStyle: {
  118. color: "#DADADA", //刻度线的颜色
  119. },
  120. },
  121. splitLine: {
  122. //网格线
  123. lineStyle: {
  124. type: "dotted", //设置网格线类型 dotted:虚线 solid:实线
  125. },
  126. show: true, //隐藏或显示
  127. },
  128. axisLabel: {
  129. color: "#5F6E82", //更改坐标轴文字颜色
  130. },
  131. }, ],
  132. series: series_data
  133. };
  134. var myEcharts = echarts.init(document.querySelector(".section_2_level.level_" + s_index + " #classLevelEcharts"));
  135. myEcharts.clear();
  136. myEcharts.setOption(option);
  137. }
  138. //图表数据
  139. function showgraphicaldata(xAxis_data, legend_data, levelrangeObj, s_index, list) {
  140. //图表数据
  141. var arr = JSON.parse(JSON.stringify(list));
  142. var goodTableHeadTr1Html = '<th rowspan="2">班级</th>';
  143. var goodTableHeadTr2Html = '';
  144. var goodTableTbodyHtml = "";
  145. $.each(legend_data, function (idx, item) {
  146. goodTableHeadTr1Html += '<th colspan="2">' + item + levelrangeObj[idx] + '</th>';
  147. goodTableHeadTr2Html += '<th>人数</th><th>比例</th>';
  148. });
  149. $.each(xAxis_data, function (idx, item) {
  150. var trHtml = '<td><div class="my_cell">' + item + '</div></td>'
  151. var classs = $.grep(arr, function (val) {
  152. return val.classname == item;
  153. });
  154. $.each(legend_data, function (idx, item) {
  155. var rank = $.grep(classs, function (val) {
  156. return val.rankname + '类' == item;
  157. })[0];
  158. trHtml += '<td><div class="my_cell">' + rank.stunum +
  159. '</div></td><td><div class="my_cell">' + rank.sturate +
  160. '%</div></td>'
  161. });
  162. goodTableTbodyHtml += '<tr>' + trHtml + '</tr>';
  163. });
  164. $(".section_2_level.level_" + s_index + " .goodTableHeadTr1").html(goodTableHeadTr1Html);
  165. $(".section_2_level.level_" + s_index + " .goodTableHeadTr2").html(goodTableHeadTr2Html);
  166. $(".section_2_level.level_" + s_index + " .goodTableTbody").html(goodTableTbodyHtml);
  167. var totalObj = {};
  168. var maxObj = {};
  169. var minObj = {};
  170. var classObj = {};
  171. $.each(list, function(index, listItem) {
  172. if (!totalObj[listItem.rankname]) {
  173. totalObj[listItem.rankname] = {};
  174. }
  175. if (!maxObj[listItem.rankname]) {
  176. maxObj[listItem.rankname] = {
  177. stunum: 0,
  178. classidArr: []
  179. };
  180. }
  181. if (listItem.classid === 0) {
  182. totalObj[listItem.rankname].stunum = listItem.stunum;
  183. totalObj[listItem.rankname].sturate = listItem.sturate;
  184. } else {
  185. classObj[listItem.classid] = listItem.classname;
  186. if (maxObj[listItem.rankname].stunum < listItem.stunum) {
  187. maxObj[listItem.rankname].stunum = listItem.stunum;
  188. maxObj[listItem.rankname].classidArr = [ listItem.classid ];
  189. } else if (maxObj[listItem.rankname].stunum === listItem.stunum) {
  190. maxObj[listItem.rankname].classidArr.push(listItem.classid);
  191. }
  192. }
  193. });
  194. $.each(list, function(index, listItem) {
  195. if (!minObj[listItem.rankname]) {
  196. minObj[listItem.rankname] = {
  197. stunum: maxObj[listItem.rankname].stunum,
  198. classidArr: []
  199. };
  200. }
  201. if (listItem.classid !== 0) {
  202. if (minObj[listItem.rankname].stunum > listItem.stunum) {
  203. minObj[listItem.rankname].stunum = listItem.stunum;
  204. minObj[listItem.rankname].classidArr = [ listItem.classid ];
  205. } else if (minObj[listItem.rankname].stunum === listItem.stunum) {
  206. minObj[listItem.rankname].classidArr.push(listItem.classid);
  207. }
  208. }
  209. });
  210. $(".section_2_level.level_" + s_index + " .result_collect").text("A类" + totalObj['A'].stunum + "人(" + totalObj['A'].sturate + "%),B类" + totalObj['B'].stunum + "人(" + totalObj['B'].sturate + "%),C类" + totalObj['C'].stunum + "人(" + totalObj['C'].sturate + "%),D类" + totalObj['D'].stunum + "人(" + totalObj['D'].sturate + "%),E类" + totalObj['E'].stunum + "人(" + totalObj['E'].sturate + "%)");
  211. $(".section_2_level.level_" + s_index + " .A_collect").text("A类上线率最高的班级:" + $.map(maxObj['A'].classidArr, function (classid) {
  212. return classObj[classid];
  213. }).join('、') + ",A类上线率最低的班级:" + $.map(minObj['A'].classidArr, function (classid) {
  214. return classObj[classid];
  215. }).join('、'));
  216. $(".section_2_level.level_" + s_index + " .B_collect").text("B类上线率最高的班级:" + $.map(maxObj['B'].classidArr, function (classid) {
  217. return classObj[classid];
  218. }).join('、') + ",B类上线率最低的班级:" + $.map(minObj['B'].classidArr, function (classid) {
  219. return classObj[classid];
  220. }).join('、'));
  221. $(".section_2_level.level_" + s_index + " .C_collect").text("C类上线率最高的班级:" + $.map(maxObj['C'].classidArr, function (classid) {
  222. return classObj[classid];
  223. }).join('、') + ",C类上线率最低的班级:" + $.map(minObj['C'].classidArr, function (classid) {
  224. return classObj[classid];
  225. }).join('、'));
  226. $(".section_2_level.level_" + s_index + " .D_collect").text("D类上线率最高的班级:" + $.map(maxObj['D'].classidArr, function (classid) {
  227. return classObj[classid];
  228. }).join('、') + ",D类上线率最低的班级:" + $.map(minObj['D'].classidArr, function (classid) {
  229. return classObj[classid];
  230. }).join('、'));
  231. $(".section_2_level.level_" + s_index + " .E_collect").text("E类上线率最高的班级:" + $.map(maxObj['E'].classidArr, function (classid) {
  232. return classObj[classid];
  233. }).join('、') + ",E类上线率最低的班级:" + $.map(minObj['E'].classidArr, function (classid) {
  234. return classObj[classid];
  235. }).join('、'));
  236. }
  237. var parameter = $(".section_2_html_root .section_2_level_html_root").data("page-params");
  238. parameter = JSON.parse(parameter);
  239. // console.log(parameter);
  240. var subjectInfo = [];
  241. for (var sid in parameter) {
  242. if (sid === "zf") {
  243. subjectInfo.unshift({
  244. subjectid: sid,
  245. subjectname: "全科",
  246. ranks: parameter[sid].ranks
  247. });
  248. } else {
  249. subjectInfo.push({
  250. subjectid: sid,
  251. subjectname: parameter[sid].subjectname,
  252. ranks: parameter[sid].ranks
  253. });
  254. }
  255. }
  256. var singleRootHtml = "";
  257. $.each(subjectInfo, function (s_index, s_item) {
  258. singleRootHtml += '<div class="page_root section_2_level level_' + s_index + '">' + (s_index === 0 ? '<h2 class="section_title_2">2.分数等级对比</h2>' : '') + '<h3 class="section_title_3">2.' + (s_index + 1) + ' ' + s_item.subjectname + '等级对比</h3><h4 class="section_title_4">2.' + (s_index + 1) + '.1 各班等级分析</h4><div id="classLevelEcharts" style="margin: 0 4mm 4mm; height: 80mm"></div><h4 class="section_title_4">2.' + (s_index + 1) + '.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>';
  259. });
  260. $(".section_2_level_root").html(singleRootHtml);
  261. $.each(subjectInfo, function (s_index, s_item) {
  262. initclassLevelEcharts(s_index, s_item.ranks);
  263. });
  264. });