ソースを参照

优势学科

gzb
guozhongbo 1年前
コミット
3760e23af2
2個のファイルの変更159行の追加110行の削除
  1. 155
    108
      js/section_1.js
  2. 4
    2
      sections/section_1.html

+ 155
- 108
js/section_1.js ファイルの表示

@@ -773,7 +773,7 @@ $(function () {
773 773
     var arr = JSON.parse(JSON.stringify(list));
774 774
     var tableobj = {};
775 775
     var tablehtml = "";
776
-   $.each(xAxis_data, function (idx, item) {
776
+    $.each(xAxis_data, function (idx, item) {
777 777
       var classs = $.grep(arr, function (val) {
778 778
         return val.subjectname == item;
779 779
       });
@@ -910,158 +910,205 @@ $(function () {
910 910
     );
911 911
     myEcharts.clear();
912 912
     myEcharts.setOption(option);
913
-    showscoredistributiondata(list,xAxis_data,dataArr);
913
+    showscoredistributiondata(list, xAxis_data, dataArr);
914 914
   }
915 915
 
916
-  function showscoredistributiondata(list,xAxis_data) {
916
+  function showscoredistributiondata(list, xAxis_data) {
917 917
     var tableobj = {};
918
-    var num = -1, rownum = 6;//一行六条数据
919
-    $.each(xAxis_data,function (idx,item) {
918
+    var num = -1,
919
+      rownum = 6; //一行六条数据
920
+    $.each(xAxis_data, function (idx, item) {
920 921
       var obj = $.grep(list, function (val) {
921 922
         return val.rankname == item && val.subjectid == "zf";
922
-      })[0]
923
-       if ((idx + rownum) % rownum == 0) {
923
+      })[0];
924
+      if ((idx + rownum) % rownum == 0) {
924 925
         num++;
925
-        tableobj[num + "goodTableHeadTr1Html"] = '<th rowspan="2">班级</th>';
926
-         tableobj[num + "goodTableHeadTr2Html"] = "";
927
-          tableobj[num+"trHtml"] = '<td><div class="my_cell">全科</div></td>';
928
-      } 
929
-      tableobj[num + "goodTableHeadTr1Html"] += '<th colspan="2">' + item + "</th>";
926
+        tableobj[num + "goodTableHeadTr1Html"] = '<th rowspan="2">科目</th>';
927
+        tableobj[num + "goodTableHeadTr2Html"] = "";
928
+        tableobj[num + "trHtml"] = '<td><div class="my_cell">全科</div></td>';
929
+      }
930
+      tableobj[num + "goodTableHeadTr1Html"] +=
931
+        '<th colspan="2">' + item + "</th>";
930 932
       tableobj[num + "goodTableHeadTr2Html"] += "<th>人数</th><th>比例</th>";
931
-       tableobj[num+"trHtml"] +=
932
-          '<td><div class="my_cell">' +
933
-          obj.stunum +
934
-          '</div></td><td><div class="my_cell">' +
935
-          obj.sturate +
936
-          "%</div></td>";
937
-    })
938
-       //计算表格高度 页面高1047 剩余高度582 表头62.5  内容27.42
939
-    var tableheight = (27.5+62.5 +15) *(num+1);
933
+      tableobj[num + "trHtml"] +=
934
+        '<td><div class="my_cell">' +
935
+        obj.stunum +
936
+        '</div></td><td><div class="my_cell">' +
937
+        obj.sturate +
938
+        "%</div></td>";
939
+    });
940
+    //计算表格高度 页面高1047 剩余高度582 表头62.5  内容27.42
941
+    var tableheight = (27.5 + 62.5 + 15) * (num + 1);
940 942
     var page = {
941
-      1:"",2:"",3:""
943
+      1: "",
944
+      2: "",
945
+      3: ""
942 946
     }; //页数
943 947
     var table = "";
944 948
     var itemheight = 27.5 + 62.5 + 15; //单表高度
945 949
     var maxheight = 0;
946
-    for (var i = 0; i < num + 1; i++){
947
-      maxheight = itemheight * (i + 1)
948
-      var content = '  <table border="1" class="my_table"><thead><tr class="goodTableHeadTr1">' +
949
-        tableobj[i + "goodTableHeadTr1Html"] + '</tr><tr class="goodTableHeadTr2">' +
950
-        tableobj[i + "goodTableHeadTr2Html"] + '</tr></thead><tbody class="goodTableTbody">' +
951
-        tableobj[i + "trHtml"] + '</tbody></table>';
950
+    for (var i = 0; i < num + 1; i++) {
951
+      maxheight = itemheight * (i + 1);
952
+      var content =
953
+        '  <table border="1" class="my_table"><thead><tr class="goodTableHeadTr1">' +
954
+        tableobj[i + "goodTableHeadTr1Html"] +
955
+        '</tr><tr class="goodTableHeadTr2">' +
956
+        tableobj[i + "goodTableHeadTr2Html"] +
957
+        '</tr></thead><tbody class="goodTableTbody">' +
958
+        tableobj[i + "trHtml"] +
959
+        "</tbody></table>";
952 960
       //计算剩余高度是否能显示最后一个表格
953
-      if (maxheight > 582 && 582-maxheight<itemheight) {
961
+      if (maxheight > 582 && 582 - maxheight < itemheight) {
954 962
         page[1] += content;
955
-      } else if (maxheight > 1629 && 1629-maxheight<itemheight) {
963
+      } else if (maxheight > 1629 && 1629 - maxheight < itemheight) {
956 964
         page[2] += content;
957 965
       } else {
958 966
         table += content;
959 967
       }
960 968
     }
961
-       $(".table_num0 .scoredistribution").html(table);
969
+    $(".table_num0 .scoredistribution").html(table);
962 970
     if (tableheight > 582) {
963 971
       //添加第一页
964
-      $(".table_num0").after('<div class="page_root section_2_part table_num1"></div>')
972
+      $(".table_num0").after(
973
+        '<div class="page_root section_2_part table_num1"></div>'
974
+      );
965 975
       $(".table_num1").html(page[1]);
966 976
     } else if (tableheight > 1629) {
967 977
       //添加第二页
968
-      $(".table_num1").after('<div class="page_root section_2_part table_num2"></div>')
978
+      $(".table_num1").after(
979
+        '<div class="page_root section_2_part table_num2"></div>'
980
+      );
969 981
       $(".table_num2").html(page[2]);
970
-    } 
982
+    }
971 983
   }
972 984
 
973 985
   function initgoodbadSubjectEcharts(list) {
974 986
     console.log(list);
975 987
     var schoolrate = [],
976
-        classrate = [],
977
-        legendlist = [list[0].classname, "全年级"];
978
-      this.subjectscore.forEach((item) => {
979
-        if (item.subjectname != "总分") {
980
-          classrate.push(
981
-            parseInt(
982
-              ((item.classavgscore - item.schoolavgscore) / item.bzc) * 10000
983
-            ) / 100 || 0
984
-          );
985
-          schoolrate.push(
986
-            parseInt((item.classavgscore / item.schoolavgscore) * 10000) / 100 || 0
987
-          );
988
-        }
989
-      });
990
-      // 求出数组最大值
991
-      let arr = [...schoolrate, ...classrate];
992
-      let arr1 = Math.max.apply(null, arr);
993
-      let maxnum = parseInt((arr1 + 10) / 10) * 10;
994
-      let arrList = [];
995
-      for (let i = 0; i < this.subjectscore.length; i++) {
996
-        let item = this.subjectscore[i];
997
-        if (item.subjectname == "总分") {
998
-          continue;
999
-        }
988
+      classrate = [],
989
+      legendlist = [ "全年级",list[0].classname];
990
+    console.log(legendlist);
991
+    $.each(list, function (idx, item) {
992
+      if (item.subjectname != "全科") {
993
+           classrate.push(
994
+        parseInt(
995
+          ((item.classavgscore - item.schoolavgscore) / item.bzc) * 10000
996
+        ) / 100 || 0
997
+      );
998
+      schoolrate.push(
999
+        parseInt((item.classavgscore / item.schoolavgscore) * 10000) / 100 || 0
1000
+      );
1001
+      }
1002
+    });
1003
+    // 求出数组最大值
1004
+    let arr = [...schoolrate, ...classrate],yssubject = "",lssubject = "";
1005
+    let arr1 = Math.max.apply(null, arr);
1006
+    let maxnum = parseInt((arr1 + 10) / 10) * 10;
1007
+    let arrList = [];
1008
+    $.each(list, function (idx, item) {
1009
+      if (item.subjectname != "全科") {
1000 1010
         let j = {
1001 1011
           name: item.subjectname,
1002 1012
           max: maxnum
1003 1013
         };
1004 1014
         arrList.push(j);
1015
+         if (item.bzc > item.qkbzc) {
1016
+                yssubject += item.subjectname + "、";
1017
+              } else {
1018
+                lssubject += item.subjectname + "、";
1019
+              }
1005 1020
       }
1006
-      var option = {
1007
-        animation: false,
1008
-        color: ["#5C99FF", "#FF5F56", "#5EC5C8", "#f1982b"],
1009
-        legend: {
1010
-          icon: "rectRound",
1011
-          itemWidth: 6,
1012
-          itemHeight: 6,
1013
-          data: legendlist,
1014
-          x: "center",
1015
-          y: "bottom"
1016
-        },
1017
-        grid: {
1018
-          //直角坐标系内绘图网格
1019
-          left: "3%",
1020
-          right: "3%",
1021
-          bottom: "10%", //grid 组件离容器下侧的距离。
1022
-          containLabel: true //grid 区域是否包含坐标轴的刻度标签。
1023
-        },
1024
-        radar: {
1025
-          radius: "60%",
1026
-          center: ["50%", "55%"],
1027
-          indicator: arrList
1021
+    });
1022
+    yssubject = yssubject.substr(0, yssubject.length - 1);
1023
+    lssubject = lssubject.substr(0, lssubject.length - 1);
1024
+    $(".section1 .yssubject").text(yssubject); // 优势
1025
+    $(".section1 .lssubject").text(lssubject); // 劣势
1026
+    var option = {
1027
+      animation: false,
1028
+      color: ["#5C99FF", "#FF5F56", "#5EC5C8", "#f1982b"],
1029
+      legend: {
1030
+        icon: "rectRound",
1031
+        itemWidth: $.UnitUtil.mm2px(2),
1032
+        itemHeight: $.UnitUtil.mm2px(2),
1033
+        data: legendlist,
1034
+        x: "center",
1035
+        y: "bottom"
1036
+      },
1037
+      grid: {
1038
+        top: $.UnitUtil.mm2px(10),
1039
+        left: 0,
1040
+        right: 0,
1041
+        bottom: $.UnitUtil.mm2px(8),
1042
+        containLabel: true
1043
+      },
1044
+      radar: {
1045
+        radius: "60%",
1046
+        center: ["50%", "55%"],
1047
+        indicator: arrList
1048
+      },
1049
+      series: {
1050
+        type: "radar",
1051
+        tooltip: {
1052
+          trigger: "item"
1028 1053
         },
1029
-        series: {
1030
-          type: "radar",
1031
-          tooltip: {
1032
-            trigger: "item"
1054
+        // areaStyle: {},  //内部阴影
1055
+        data: [
1056
+         {
1057
+            value: schoolrate,
1058
+            label: {
1059
+              show: true,
1060
+              formatter: function (params) {
1061
+                return params.value;
1062
+              }
1063
+            },
1064
+            name: "全年级"
1033 1065
           },
1034
-          // areaStyle: {},  //内部阴影
1035
-          data: [
1036
-            {
1037
-              value: classrate,
1038
-              label: {
1039
-                show: true,
1040
-                formatter: function (params) {
1041
-                  return params.value;
1042
-                }
1043
-              },
1044
-              name: this.classname
1066
+          {
1067
+            value: classrate,
1068
+            label: {
1069
+              show: true,
1070
+              formatter: function (params) {
1071
+                return params.value;
1072
+              }
1045 1073
             },
1046
-            {
1047
-              value: schoolrate,
1048
-              label: {
1049
-                show: true,
1050
-                formatter: function (params) {
1051
-                  return params.value;
1052
-                }
1053
-              },
1054
-              name: "全年级"
1055
-            }
1056
-          ]
1057
-        }
1074
+            name: list[0].classname
1075
+          }
1076
+        ]
1077
+      }
1058 1078
     };
1059 1079
     var myEcharts = echarts.init(
1060 1080
       document.querySelector(".section1 #goodbadSubjectEcharts")
1061 1081
     );
1062 1082
     myEcharts.clear();
1063 1083
     myEcharts.setOption(option);
1064
-    
1084
+    showgoodbadtable(list,legendlist,schoolrate,classrate);
1085
+  }
1086
+
1087
+  function showgoodbadtable (list, legendlist, schoolrate, classrate) {
1088
+    var table = "", goodTableHeadTr1Html = '<th rowspan="2">班级</th>', goodTableHeadTr2Html = "", trHtml = "";
1089
+    $.each(list, function (idx, item) {
1090
+      if (item.subjectname != "全科") { 
1091
+         goodTableHeadTr1Html += '<th colspan="2">' + item.subjectname + "</th>";
1092
+      }
1093
+    })
1094
+    $.each(legendlist, function (idx, item) {
1095
+      trHtml += '<tr><th colspan="2">' + item + "</th>";
1096
+      if (idx == 0) {
1097
+        $.each(schoolrate, function (idx, item) {
1098
+        trHtml += '<th colspan="2">' + item + "%</th>";
1099
+      })
1100
+      } else {
1101
+          $.each(classrate, function (idx, item) {
1102
+        trHtml += '<th colspan="2">' + item + "%</th>";
1103
+      })
1104
+      }
1105
+       
1106
+    })
1107
+    table = '<table border="1" class="my_table"><thead><tr class="goodTableHeadTr1">' +
1108
+        goodTableHeadTr1Html + '</tr></thead><tbody class="goodTableTbody">' +
1109
+      trHtml + '</tbody></table>'
1110
+    $(".section1 .goodbadtable").html(table); 
1111
+    console.log(table);
1065 1112
   }
1066 1113
   var parameter = JSON.parse($(".section_1_html_root").data("page-params"));
1067 1114
   var xAxis_data = [],

+ 4
- 2
sections/section_1.html ファイルの表示

@@ -165,16 +165,18 @@
165 165
         <div>上图统计结果表示:</div>
166 166
         <div class="echarts_result_content">
167 167
           <span class="yj" style="background-color: #5c99ff"></span
168
-          >优势学科:<span class="goodsubject"></span>
168
+          >优势学科:<span class="yssubject"></span>
169 169
         </div>
170 170
         <div
171 171
           class="echarts_result_content"
172 172
           style="margin-top: 0; padding-top: 0"
173 173
         >
174 174
           <span class="yj" style="background-color: #ff5f56"></span
175
-          >劣势学科<span class="badsubject"></span>
175
+          >劣势学科<span class="lssubject"></span>
176 176
         </div>
177 177
       </div>
178
+      <h3 class="section_title_3">5.2 各科优劣比例分布</h3>
179
+      <div class="goodbadtable"></div>
178 180
     </div>
179 181
     <script src="../js/section_1.js"></script>
180 182
   </body>

読み込み中…
キャンセル
保存