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_lin.js 9.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. $(function () {
  2. // 按名次统计
  3. function initClassCriticalRankEcharts(r_data_item, s_index) {
  4. var linescore = r_data_item.linescore;
  5. var legend_data = [">" + linescore + "名", "≤" + linescore + "名"];
  6. var xAxis_data = [];
  7. var series_data1 = [];
  8. var series_data2 = [];
  9. $.each(r_data_item.ranks, function(index, r_item) {
  10. xAxis_data.push(r_item.classname);
  11. series_data1.push(r_item.dynum);
  12. series_data2.push(-r_item.xynum);
  13. });
  14. var option = {
  15. title: {
  16. text: "人",
  17. x: "left",
  18. y: "top",
  19. textStyle: {
  20. color: "#5F6E82",
  21. fontSize: 12,
  22. fontWeight: 500
  23. }
  24. },
  25. color: ["#5C99FF", "#F39A2C"],
  26. legend: {
  27. itemWidth: 6,
  28. itemHeight: 6,
  29. bottom: 30,
  30. data: legend_data
  31. },
  32. grid: {
  33. top: 30,
  34. left: 5,
  35. right: 0,
  36. bottom: 65,
  37. containLabel: true
  38. },
  39. xAxis: [
  40. {
  41. type: "category",
  42. offset: 10,
  43. position: "bottom",
  44. data: xAxis_data,
  45. axisLabel: {
  46. color: "#5F6E82" //更改坐标轴文字颜色
  47. },
  48. axisTick: {
  49. alignWithLabel: true
  50. },
  51. boundaryGap: true,
  52. triggerEvent: true,
  53. axisLine: {
  54. show: true, //是否显示轴线
  55. lineStyle: {
  56. color: "#DADADA" //刻度线的颜色
  57. }
  58. }
  59. }
  60. ],
  61. yAxis: [
  62. {
  63. type: "value",
  64. axisTick: {
  65. show: false //刻度
  66. },
  67. axisLine: {
  68. show: false, //是否显示轴线
  69. lineStyle: {
  70. color: "#DADADA" //刻度线的颜色
  71. }
  72. },
  73. splitLine: {
  74. //网格线
  75. lineStyle: {
  76. type: "dotted" //设置网格线类型 dotted:虚线 solid:实线
  77. },
  78. show: true //隐藏或显示
  79. },
  80. axisLabel: {
  81. color: "#5F6E82" //更改坐标轴文字颜色
  82. }
  83. }
  84. ],
  85. series: [
  86. {
  87. name: legend_data[0],
  88. type: "bar",
  89. stack: "one",
  90. barWidth: 32,
  91. // 柱状图最小高度
  92. barMinHeight: 0,
  93. barGap: 0,
  94. label: {
  95. normal: {
  96. show: true,
  97. align: "center",
  98. verticalAlign: "bottom",
  99. position: "top",
  100. distance: 0
  101. }
  102. },
  103. data: series_data1
  104. },
  105. {
  106. name: legend_data[1],
  107. type: "bar",
  108. stack: "one",
  109. barWidth: 32,
  110. // 柱状图最小高度
  111. barMinHeight: 0,
  112. barGap: 0,
  113. label: {
  114. normal: {
  115. show: true,
  116. align: "center",
  117. verticalAlign: "top",
  118. position: "bottom",
  119. distance: 0,
  120. formatter: function (params) {
  121. return Math.abs(params.value);
  122. }
  123. }
  124. },
  125. data: series_data2
  126. }
  127. ]
  128. };
  129. var myEcharts = echarts.init(document.querySelector(".section_2_lin_" + s_index + " #classCriticalRankEcharts"));
  130. myEcharts.clear();
  131. myEcharts.setOption(option);
  132. }
  133. // 按分数统计
  134. function initClassCriticalScoreEcharts(s_data_item, s_index) {
  135. var linescore = s_data_item.linescore;
  136. var legend_data = [">" + linescore + "分", "≤" + linescore + "分"];
  137. var xAxis_data = [];
  138. var series_data1 = [];
  139. var series_data2 = [];
  140. $.each(s_data_item.ranks, function(index, r_item) {
  141. xAxis_data.push(r_item.classname);
  142. series_data1.push(r_item.dynum);
  143. series_data2.push(-r_item.xynum);
  144. });
  145. var option = {
  146. title: {
  147. text: "人",
  148. x: "left",
  149. y: "top",
  150. textStyle: {
  151. color: "#5F6E82",
  152. fontSize: 12,
  153. fontWeight: 500
  154. }
  155. },
  156. color: ["#5C99FF", "#F39A2C"],
  157. legend: {
  158. itemWidth: 6,
  159. itemHeight: 6,
  160. bottom: 30,
  161. data: legend_data
  162. },
  163. grid: {
  164. top: 30,
  165. left: 5,
  166. right: 0,
  167. bottom: 65,
  168. containLabel: true
  169. },
  170. xAxis: [
  171. {
  172. type: "category",
  173. offset: 10,
  174. position: "bottom",
  175. data: xAxis_data,
  176. axisLabel: {
  177. color: "#5F6E82" //更改坐标轴文字颜色
  178. },
  179. axisTick: {
  180. alignWithLabel: true
  181. },
  182. boundaryGap: true,
  183. triggerEvent: true,
  184. axisLine: {
  185. show: true, //是否显示轴线
  186. lineStyle: {
  187. color: "#DADADA" //刻度线的颜色
  188. }
  189. }
  190. }
  191. ],
  192. yAxis: [
  193. {
  194. type: "value",
  195. axisTick: {
  196. show: false //刻度
  197. },
  198. axisLine: {
  199. show: false, //是否显示轴线
  200. lineStyle: {
  201. color: "#DADADA" //刻度线的颜色
  202. }
  203. },
  204. splitLine: {
  205. //网格线
  206. lineStyle: {
  207. type: "dotted" //设置网格线类型 dotted:虚线 solid:实线
  208. },
  209. show: true //隐藏或显示
  210. },
  211. axisLabel: {
  212. color: "#5F6E82" //更改坐标轴文字颜色
  213. }
  214. }
  215. ],
  216. series: [
  217. {
  218. name: legend_data[0],
  219. type: "bar",
  220. stack: "one",
  221. barWidth: 32,
  222. // 柱状图最小高度
  223. barMinHeight: 0,
  224. barGap: 0,
  225. label: {
  226. normal: {
  227. show: true,
  228. align: "center",
  229. verticalAlign: "bottom",
  230. position: "top",
  231. distance: 0
  232. }
  233. },
  234. data: series_data1
  235. },
  236. {
  237. name: legend_data[1],
  238. type: "bar",
  239. stack: "one",
  240. barWidth: 32,
  241. // 柱状图最小高度
  242. barMinHeight: 0,
  243. barGap: 0,
  244. label: {
  245. normal: {
  246. show: true,
  247. align: "center",
  248. verticalAlign: "top",
  249. position: "bottom",
  250. distance: 0,
  251. formatter: function (params) {
  252. return Math.abs(params.value);
  253. }
  254. }
  255. },
  256. data: series_data2
  257. }
  258. ]
  259. };
  260. var myEcharts = echarts.init(document.querySelector(".section_2_lin #classCriticalScoreEcharts"));
  261. myEcharts.clear();
  262. myEcharts.setOption(option);
  263. }
  264. var parameter = $(".section_2_html_root .section_2_lin_html_root").data("page-params");
  265. parameter = JSON.parse(parameter);
  266. var subjectInfo = [];
  267. var subjectid_ranktype = {};
  268. for(var sid_3 in parameter[3]) {
  269. if (sid_3 === "zf") {
  270. subjectInfo.unshift({
  271. subjectid: sid_3,
  272. subjectname: "全科"
  273. });
  274. } else {
  275. subjectInfo.push({
  276. subjectid: sid_3,
  277. subjectname: parameter[3][sid_3].subjectname
  278. });
  279. }
  280. if (!subjectid_ranktype[sid_3]) {
  281. subjectid_ranktype[sid_3] = {};
  282. }
  283. subjectid_ranktype[sid_3][3] = parameter[3][sid_3];
  284. }
  285. for(var sid_4 in parameter[4]) {
  286. if (!subjectid_ranktype[sid_4]) {
  287. subjectid_ranktype[sid_4] = {};
  288. }
  289. subjectid_ranktype[sid_4][4] = parameter[4][sid_4];
  290. }
  291. console.log("subjectid_ranktype", subjectid_ranktype);
  292. var singleRootHtml = "";
  293. $.each(subjectInfo, function(s_index, s_item) {
  294. if (s_index === 0) {
  295. console.log("s_index", s_index);
  296. console.log("s_item", s_item);
  297. }
  298. });
  299. $(".section_2_lin_root").html(singleRootHtml);
  300. var s_index = 0;
  301. var s_item = subjectInfo[s_index];
  302. var r_data_item = subjectid_ranktype[s_item.subjectid][4];
  303. console.log("r_data_item", r_data_item);
  304. // 按名次统计
  305. $(".section_2_lin_0 .subjectname").text(r_data_item.subjectname);
  306. $(".section_2_lin_0 .lin_rank_num").text(r_data_item.linescore);
  307. $(".section_2_lin_0 .lin_rank_float").text(r_data_item.floatscore);
  308. $(".section_2_lin_0 .lin_rank_range").text(r_data_item.maxscore + " - " + r_data_item.minscore);
  309. initClassCriticalRankEcharts(r_data_item, s_index);
  310. var lin_rank_tbody_html = "";
  311. var linRankMaxInfo = {
  312. stunum: 0,
  313. classname: ""
  314. };
  315. $.each(r_data_item.ranks, function(index, r_item) {
  316. if (r_item.classid !== 0 && linRankMaxInfo.stunum < r_item.stunum) {
  317. linRankMaxInfo.stunum = r_item.stunum;
  318. linRankMaxInfo.classname = r_item.classname;
  319. }
  320. lin_rank_tbody_html += '<tr><td><div class="my_cell">' + r_item.classname + '</div></td><td><div class="my_cell">' + r_item.stunum + '</div></td><td><div class="my_cell">' + r_item.sturate + '%</div></td></tr>'
  321. });
  322. $(".section_2_lin_0 .lin_rank_tbody").html(lin_rank_tbody_html);
  323. $(".section_2_lin_0 .lin_rank_max").html(linRankMaxInfo.classname);
  324. // 按分数统计
  325. var s_data_item = subjectid_ranktype[s_item.subjectid][3];
  326. console.log("s_data_item", s_data_item);
  327. $(".section_2_lin_0 .lin_score_num").text(s_data_item.linescore);
  328. $(".section_2_lin_0 .lin_score_float").text(s_data_item.floatscore);
  329. $(".section_2_lin_0 .lin_score_range").text(s_data_item.minscore + " - " + s_data_item.maxscore);
  330. initClassCriticalScoreEcharts(s_data_item, s_index);
  331. var lin_score_tbody_html = "";
  332. var linScoreMaxInfo = {
  333. stunum: 0,
  334. classname: ""
  335. };
  336. $.each(s_data_item.ranks, function(index, r_item) {
  337. if (r_item.classid !== 0 && linScoreMaxInfo.stunum < r_item.stunum) {
  338. linScoreMaxInfo.stunum = r_item.stunum;
  339. linScoreMaxInfo.classname = r_item.classname;
  340. }
  341. lin_score_tbody_html += '<tr><td><div class="my_cell">' + r_item.classname + '</div></td><td><div class="my_cell">' + r_item.stunum + '</div></td><td><div class="my_cell">' + r_item.sturate + '%</div></td></tr>'
  342. });
  343. $(".section_2_lin_0 .lin_score_tbody").html(lin_score_tbody_html);
  344. $(".section_2_lin_0 .lin_score_max").html(linScoreMaxInfo.classname);
  345. });