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_3.js 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. $(function () {
  2. function initSubjectBadEcharts(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_3 #subjectBadEcharts"));
  97. myEcharts.clear();
  98. myEcharts.setOption(option);
  99. }
  100. var parameter = $(".section_3_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 badTableHeadTr1Html = '<th rowspan="2">班级</th>';
  137. var badTableHeadTr2Html = '';
  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. badTableHeadTr1Html += '<th colspan="2">' + subjectid_subjectname[subjectid] + '</th>';
  149. badTableHeadTr2Html += '<th>人数</th><th>比例</th>';
  150. }
  151. $(".section_3 .subjectBadMaxNum").text(maxSubjectInfo.subjectname);
  152. initSubjectBadEcharts(xAxis_data, series_data);
  153. var maxClassInfo = {
  154. num: 0,
  155. classname: ""
  156. };
  157. var badTableTbodyHtml = "";
  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. badTableTbodyHtml += '<tr>' + trHtml + '</tr>';
  172. }
  173. $(".section_3 .classBadMaxNum").text(maxClassInfo.classname);
  174. $(".section_3 .badTableHeadTr1").html(badTableHeadTr1Html);
  175. $(".section_3 .badTableHeadTr2").html(badTableHeadTr2Html);
  176. $(".section_3 .badTableTbody").html(badTableTbodyHtml);
  177. });