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_part.js 7.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. $(function () {
  2. function classscorePartEcharts (s_index, obj) {
  3. var legend_data = [];
  4. legend_data.push(obj.subjectname);
  5. var xAxis_data = [];
  6. var dataArr = [];
  7. var list = $.grep(obj.ranks, function (val) {
  8. return val.classid == 0;
  9. });
  10. $.each(list, function (index, item) {
  11. xAxis_data.push(item.rankname);
  12. dataArr.push(item.stunum);
  13. });
  14. var series_data = [
  15. {
  16. name: obj.subjectname,
  17. type: "line",
  18. symbol: "circle",
  19. stack: obj.subjectname,
  20. label: {
  21. normal: {
  22. show: true,
  23. align: "center",
  24. verticalAlign: "bottom",
  25. position: "top",
  26. distance: 0,
  27. formatter: "{c}"
  28. }
  29. },
  30. data: dataArr
  31. }
  32. ];
  33. var option = {
  34. animation: false,
  35. title: {
  36. text: "人",
  37. x: "left",
  38. y: "top",
  39. textStyle: {
  40. color: "#5F6E82",
  41. fontSize: $.UnitUtil.mm2px(3),
  42. fontWeight: 500
  43. }
  44. },
  45. color: ["#5C99FF", "#ff5f56", "#5EC5C8", "#f1982b", "#6e5eff"],
  46. legend: {
  47. icon: "roundRect",
  48. itemWidth: $.UnitUtil.mm2px(2),
  49. itemHeight: $.UnitUtil.mm2px(2),
  50. top: "bottom",
  51. data: legend_data
  52. },
  53. grid: {
  54. top: $.UnitUtil.mm2px(10),
  55. left: 0,
  56. right: 0,
  57. bottom: $.UnitUtil.mm2px(8),
  58. containLabel: true
  59. },
  60. xAxis: {
  61. type: "category",
  62. axisLabel: {
  63. textStyle: {
  64. color: "#5F6E82"
  65. },
  66. interval: 2,
  67. rotate: 0
  68. },
  69. axisTick: {
  70. show: false
  71. },
  72. data: xAxis_data
  73. },
  74. yAxis: {
  75. axisLabel: {
  76. textStyle: {
  77. color: "#9B9B9BFF"
  78. },
  79. interval: 0
  80. },
  81. minInterval: 1,
  82. axisLine: {
  83. show: false
  84. },
  85. axisTick: {
  86. show: false
  87. },
  88. splitLine: {
  89. //网格线
  90. lineStyle: {
  91. type: "solid", //设置网格线类型 dotted:虚线 solid:实线
  92. color: "#DADADA"
  93. },
  94. show: true //隐藏或显示
  95. },
  96. type: "value"
  97. },
  98. series: series_data
  99. };
  100. var myEcharts = echarts.init(
  101. $(".part_" + s_index + " #classPartEcharts")[0]
  102. );
  103. myEcharts.clear();
  104. myEcharts.setOption(option);
  105. showgraphicaldata(obj, xAxis_data, s_index);
  106. }
  107. function showgraphicaldata (obj, xAxis_data, s_index) {
  108. //图表数据
  109. var data = JSON.parse(JSON.stringify(obj));
  110. var calsslist = [];
  111. var tableobj = {};
  112. var num = -1;
  113. var rownum = 6;//一行七条数据
  114. // if(s_index != 0) return
  115. $.each(xAxis_data, function (idx, item) {
  116. if ((idx + rownum) % rownum == 0) {
  117. num++;
  118. tableobj[num+"trHtml"] = "";
  119. tableobj[num + "goodTableHeadTr1Html"] = '<th rowspan="2">班级</th>';
  120. tableobj[num + "goodTableHeadTr2Html"] = "";
  121. }
  122. tableobj[num + "goodTableHeadTr1Html"] += '<th colspan="2">' + item + "</th>";
  123. tableobj[num+"goodTableHeadTr2Html"]+= "<th>人数</th><th>比例</th>";
  124. });
  125. $.each(data.ranks, function (idx, item) {
  126. if ($.inArray(item.classname, calsslist) == -1) {
  127. calsslist.push(item.classname);
  128. }
  129. })
  130. $.each(calsslist, function (index, items) {
  131. var num = -1;
  132. var classs = $.grep(data.ranks, function (val) {
  133. return val.classname == items;
  134. });
  135. $.each(xAxis_data, function (idx, item) {
  136. var rank = $.grep(classs, function (val) {
  137. return val.rankname == item;
  138. })[0];
  139. if ((idx + rownum) % rownum == 0) {
  140. num++;
  141. if (index == 0) {
  142. tableobj[num + "trHtml"] += "<tr>";
  143. } else {
  144. tableobj[num + "trHtml"] += "</tr><tr>";
  145. }
  146. tableobj[num+"trHtml"] += '<td><div class="my_cell">' + items + "</div></td>";
  147. }
  148. tableobj[num+"trHtml"] +=
  149. '<td><div class="my_cell">' +
  150. rank.stunum +
  151. '</div></td><td><div class="my_cell">' +
  152. rank.sturate +
  153. "%</div></td>";
  154. });
  155. })
  156. //计算表格高度 页面高1047 剩余高度700 表头62.5 内容27.42
  157. var tableheight = (calsslist.length * 27.5+62.5 +15) * (num+1);
  158. var page = {
  159. 1:"",2:"",3:""
  160. }; //页数
  161. var table = "";
  162. var itemheight = calsslist.length * 27.5 + 62.5 + 15; //单表高度
  163. var maxheight = 0;
  164. for (var i = 0; i < num + 1; i++){
  165. maxheight = itemheight * (i + 1)
  166. var content = ' <table border="1" class="my_table"><thead><tr class="goodTableHeadTr1">' +
  167. tableobj[i + "goodTableHeadTr1Html"] + '</tr><tr class="goodTableHeadTr2">' +
  168. tableobj[i + "goodTableHeadTr2Html"] + '</tr></thead><tbody class="goodTableTbody">' +
  169. tableobj[i + "trHtml"] + '</tbody></table>';
  170. //计算剩余高度是否能显示最后一个表格
  171. if (maxheight > 700 || 700-maxheight<itemheight) {
  172. page[1] += content;
  173. } else if (maxheight > 1747 || 1747-maxheight<itemheight) {
  174. page[2] += content;
  175. } else {
  176. table += content;
  177. }
  178. }
  179. $(".part_" + s_index + " .table_" + s_index + " ").html(table);
  180. if (tableheight > 700) {
  181. //添加第一页
  182. $(".part_" + s_index).after('<div class="page_root section_2_part part_' +
  183. s_index +
  184. '_1"></div>')
  185. $(".part_" + s_index + "_1").html(page[1]);
  186. } else if (tableheight > 1747) {
  187. //添加第二页
  188. $(".part_" + s_index+'_1').after('<div class="page_root section_2_part part_' +
  189. s_index +
  190. '_2"></div>')
  191. $(".part_" + s_index + "_2").html(page[2]);
  192. }
  193. }
  194. var parameter = $(".section_2_html_root .section_2_part_html_root").data(
  195. "page-params"
  196. );
  197. parameter = JSON.parse(parameter);
  198. // console.log(parameter);
  199. var subjectInfo = [];
  200. for (var sid in parameter) {
  201. if (sid === "zf") {
  202. subjectInfo.unshift({
  203. subjectid: sid,
  204. subjectname: "全部年级",
  205. ranks: parameter[sid].ranks,
  206. maxscore: parameter[sid].maxscore
  207. });
  208. } else {
  209. subjectInfo.push({
  210. subjectid: sid,
  211. subjectname: parameter[sid].subjectname,
  212. ranks: parameter[sid].ranks,
  213. maxscore: parameter[sid].maxscore
  214. });
  215. }
  216. }
  217. var singleRootHtml = "";
  218. $.each(subjectInfo, function (s_index, s_item) {
  219. singleRootHtml +=
  220. '<div class="page_root section_2_part part_' +
  221. s_index +
  222. '">' +
  223. (s_index === 0 ? '<h2 class="section_title_2">3.分数分段对比</h2>' : "") +
  224. '<h3 class="section_title_3">3.' +
  225. (s_index + 1) +
  226. " " +
  227. s_item.subjectname +
  228. '分数段统计</h3><h4 class="section_title_4">3.' +
  229. (s_index + 1) +
  230. '.1 各分数段分析</h4><div>当前设置分数段:<span class="curscorepart">10</span>分/段</div><div id="classPartEcharts" style="margin: 0 4mm 4mm; height: 80mm"></div><h4 class="section_title_4" > 3.' +
  231. (s_index + 1) +
  232. '.2 各班等级比例分布 </h4><div class="tables table_'+s_index+'" ></div ></div > ';
  233. });
  234. $(".section_2_part_root").html(singleRootHtml);
  235. $.each(subjectInfo, function (s_index, s_item) {
  236. $(".part_ " + s_index + " .curscorepart").text(s_item.maxscore);
  237. classscorePartEcharts(s_index, s_item);
  238. // var height = $(".part_" + s_index).height()
  239. })
  240. });