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_excellent.js 7.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. $(function () {
  2. // 优秀生、学困生统计
  3. function initClassExcellenceEcharts(r_data_item, s_index) {
  4. var legend_data = ["优秀生", "学困生"];
  5. var xAxis_data = [];
  6. var series_data1 = [];
  7. var series_data2 = [];
  8. $.each(r_data_item.ranks, function (index, r_item) {
  9. xAxis_data.push(r_item.classname);
  10. series_data1.push(r_item.stujson[0].stunum);
  11. series_data2.push(-r_item.stujson[1].stunum);
  12. });
  13. var option = {
  14. title: {
  15. text: "人",
  16. x: "left",
  17. y: "top",
  18. textStyle: {
  19. color: "#5F6E82",
  20. fontSize: 12,
  21. fontWeight: 500
  22. }
  23. },
  24. color: ["#5C99FF", "#F39A2C"],
  25. legend: {
  26. itemWidth: 6,
  27. itemHeight: 6,
  28. bottom: 30,
  29. data: legend_data
  30. },
  31. grid: {
  32. top: 30,
  33. left: 5,
  34. right: 0,
  35. bottom: 65,
  36. containLabel: true
  37. },
  38. xAxis: [
  39. {
  40. type: "category",
  41. offset: 10,
  42. position: "bottom",
  43. data: xAxis_data,
  44. axisLabel: {
  45. color: "#5F6E82" //更改坐标轴文字颜色
  46. },
  47. axisTick: {
  48. alignWithLabel: true
  49. },
  50. boundaryGap: true,
  51. triggerEvent: true,
  52. axisLine: {
  53. show: true, //是否显示轴线
  54. lineStyle: {
  55. color: "#DADADA" //刻度线的颜色
  56. }
  57. }
  58. }
  59. ],
  60. yAxis: [
  61. {
  62. type: "value",
  63. axisTick: {
  64. show: false //刻度
  65. },
  66. axisLine: {
  67. show: false, //是否显示轴线
  68. lineStyle: {
  69. color: "#DADADA" //刻度线的颜色
  70. }
  71. },
  72. splitLine: {
  73. //网格线
  74. lineStyle: {
  75. type: "dotted" //设置网格线类型 dotted:虚线 solid:实线
  76. },
  77. show: true //隐藏或显示
  78. },
  79. axisLabel: {
  80. color: "#5F6E82" //更改坐标轴文字颜色
  81. }
  82. }
  83. ],
  84. series: [
  85. {
  86. name: legend_data[0],
  87. type: "bar",
  88. stack: "one",
  89. barWidth: 32,
  90. // 柱状图最小高度
  91. barMinHeight: 0,
  92. barGap: 0,
  93. label: {
  94. normal: {
  95. show: true,
  96. align: "center",
  97. verticalAlign: "bottom",
  98. position: "top",
  99. distance: 0
  100. }
  101. },
  102. data: series_data1
  103. },
  104. {
  105. name: legend_data[1],
  106. type: "bar",
  107. stack: "one",
  108. barWidth: 32,
  109. // 柱状图最小高度
  110. barMinHeight: 0,
  111. barGap: 0,
  112. label: {
  113. normal: {
  114. show: true,
  115. align: "center",
  116. verticalAlign: "top",
  117. position: "bottom",
  118. distance: 0,
  119. formatter: function (params) {
  120. return Math.abs(params.value);
  121. }
  122. }
  123. },
  124. data: series_data2
  125. }
  126. ]
  127. };
  128. var myEcharts = echarts.init(document.querySelector(".section_2_excellent.section_2_excellent_" + s_index + " #classExcellenceEcharts"));
  129. myEcharts.clear();
  130. myEcharts.setOption(option);
  131. }
  132. var parameter = $(".section_2_html_root .section_2_excellent_html_root").data("page-params");
  133. parameter = JSON.parse(parameter);
  134. // console.log(".section_2_excellent_html_root:parameter", parameter);
  135. var subjectInfo = [];
  136. for (var sid in parameter) {
  137. if (sid === "zf") {
  138. subjectInfo.unshift({
  139. subjectid: sid,
  140. subjectname: "全科",
  141. });
  142. } else {
  143. subjectInfo.push({
  144. subjectid: sid,
  145. subjectname: parameter[sid].subjectname,
  146. });
  147. }
  148. }
  149. var singleRootHtml = "";
  150. $.each(subjectInfo, function (s_index, s_item) {
  151. singleRootHtml += '<div class="page_root section_2_excellent section_2_excellent_' + s_index + '">' + (s_index === 0 ? '<h2 class="section_title_2">5. 优秀生、学困生对比</h2>' : "") + '<h3 class="section_title_3">5.' + (s_index + 1) + ' <span class="subjectname"></span>优秀生、学困生对比</h3><h4 class="section_title_4">5.' + (s_index + 1) + '.1 各班的优秀生、学困生对比</h4><div class="echarts_result">优秀生:年级前<span class="c_5699FF excellent_linescore"></span>名<span class="margin_left_6mm">学困生:年级后<span class="c_5699FF excellent_floatscore"></span>名</span></div><div id="classExcellenceEcharts" style="margin: 0 4mm 4mm;height: 120mm;"></div></div><div class="page_root section_2_excellent section_2_excellent_' + s_index + '"><h4 class="section_title_4">5.' + (s_index + 1) + '.2 各班优秀生、学困生占比分布</h4><table border="1" class="my_table"><thead><tr><th>班级</th><th class="linescore_num"></th><th>占比</th><th class="floatscore_num">后10名</th><th>占比</th></tr></thead><tbody class="excellent_rank_tbody"></tbody></table><div class="echarts_result"><div>上图统计结果表示:</div><div class="echarts_result_content"><div><span class="dot bg_5699FF"></span>年级<span class="linescore_num"></span>优秀生最多的班级:<span class="excellent_rank_good"></span></div><div><span class="dot bg_FF5F56"></span>年级<span class="floatscore_num"></span>学困生最多的班级:<span class="excellent_rank_bad"></span></div></div></div></div>';
  152. });
  153. $(".section_2_excellent_root").html(singleRootHtml);
  154. $.each(subjectInfo, function (s_index, s_item) {
  155. var r_data_item = parameter[s_item.subjectid];
  156. // console.log("r_data_item", r_data_item);
  157. $(".section_2_excellent_" + s_index + " .subjectname").text(
  158. r_data_item.subjectname
  159. );
  160. $(".section_2_excellent_" + s_index + " .excellent_linescore").text(
  161. r_data_item.linescore
  162. );
  163. $(".section_2_excellent_" + s_index + " .excellent_floatscore").text(
  164. r_data_item.floatscore
  165. );
  166. initClassExcellenceEcharts(r_data_item, s_index);
  167. var excellent_rank_tbody_html = "";
  168. // 优秀生最多的班级
  169. var goodClassInfo = {
  170. stunum: 0,
  171. classname: "",
  172. };
  173. // 学困生最多的班级
  174. var badClassInfo = {
  175. stunum: 0,
  176. classname: "",
  177. };
  178. $(".section_2_excellent_" + s_index + " .linescore_num").text("前" + r_data_item.linescore + "名");
  179. $(".section_2_excellent_" + s_index + " .floatscore_num").text("后" + r_data_item.floatscore + "名");
  180. $.each(r_data_item.ranks, function (index, r_item) {
  181. if (r_item.classid !== 0 && goodClassInfo.stunum < r_item.stujson[0].stunum) {
  182. goodClassInfo.stunum = r_item.stujson[0].stunum;
  183. goodClassInfo.classname = r_item.classname;
  184. }
  185. if (r_item.classid !== 0 && badClassInfo.stunum < r_item.stujson[0].stunum) {
  186. badClassInfo.stunum = r_item.stujson[0].stunum;
  187. badClassInfo.classname = r_item.classname;
  188. }
  189. excellent_rank_tbody_html +=
  190. '<tr><td><div class="my_cell">' +
  191. r_item.classname +
  192. '</div></td><td><div class="my_cell">' +
  193. r_item.stujson[0].stunum +
  194. '</div></td><td><div class="my_cell">' +
  195. r_item.stujson[0].sturate +
  196. '%</div></td><td><div class="my_cell">' +
  197. r_item.stujson[1].stunum +
  198. '</div></td><td><div class="my_cell">' +
  199. r_item.stujson[1].sturate +
  200. '%</div></td></tr>';
  201. });
  202. $(".section_2_excellent_" + s_index + " .excellent_rank_tbody").html(
  203. excellent_rank_tbody_html
  204. );
  205. $(".section_2_excellent_" + s_index + " .excellent_rank_good").html(
  206. goodClassInfo.classname
  207. );
  208. $(".section_2_excellent_" + s_index + " .excellent_rank_bad").html(
  209. badClassInfo.classname
  210. );
  211. });
  212. });