level.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <view class="page_view">
  3. <top-return color="#FFF" text="考试能力"></top-return>
  4. <!-- 背景 -->
  5. <view class="bg_box"></view>
  6. <!-- 头部学期信息 -->
  7. <top-semester></top-semester>
  8. <!-- 分析列表 -->
  9. <view class="card_view">
  10. <view class="card_item" style="background-color: #4169E1;height: 200rpx;">
  11. <view class="analysis_box">
  12. <view class="analysis_text">成绩波动对比</view>
  13. <view class="flex_baseline">
  14. <view class="analysis_data">{{mainExamUndulate>=quizExamUndulate?'小考':'大考'}}</view>
  15. <view class="analysis_text" style="margin-left: 20rpx;">发挥稳定</view>
  16. </view>
  17. </view>
  18. <view class="icon_box">
  19. <view v-if="mainExamUndulate>=quizExamUndulate" class="t-icon t-icon-a-bianzu7"></view>
  20. <view v-if="mainExamUndulate<quizExamUndulate" class="t-icon t-icon-a-bianzu6"></view>
  21. </view>
  22. </view>
  23. <view class="card_item" style="background-color: #ff8caf;height: 200rpx;">
  24. <view class="analysis_box">
  25. <view class="analysis_text">得分能力对比</view>
  26. <view class="flex_baseline">
  27. <view class="analysis_data">{{avgMain>=avgquiz?'大考':'小考'}}</view>
  28. <view class="analysis_text" style="margin-left: 20rpx;">得分能力强</view>
  29. </view>
  30. </view>
  31. <view class="icon_box">
  32. <view v-if="avgMain<avgquiz" class="t-icon t-icon-a-bianzu7"></view>
  33. <view v-if="avgMain>=avgquiz" class="t-icon t-icon-a-bianzu6"></view>
  34. </view>
  35. </view>
  36. <!-- 图表 -->
  37. <view class="card_item" style="width: 100%;">
  38. <view class="card_title">
  39. <view class="front_tag"></view>
  40. <view class="title">重要考试对比</view>
  41. </view>
  42. <view class="chart_box">
  43. <qiun-data-charts type="column" ontouch="true" :chartData="examChartData.levelChartData[0]"
  44. tooltipFormat='tooltipScoreShort' :canvas2d="true" canvasId="level_chart1" />
  45. </view>
  46. </view>
  47. <view class="card_item" style="width: 100%;">
  48. <view class="card_title">
  49. <view class="front_tag"></view>
  50. <view class="title">普通测验记录</view>
  51. </view>
  52. <view class="chart_box">
  53. <qiun-data-charts type="column" ontouch="true" :chartData="examChartData.levelChartData[1]"
  54. tooltipFormat='tooltipScoreShort' :canvas2d="true" canvasId="level_chart2" />
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </template>
  60. <script>
  61. import {
  62. mapState
  63. } from 'vuex'
  64. export default {
  65. computed: {
  66. ...mapState('m_chart', ['examChartData']),
  67. },
  68. data() {
  69. return {
  70. //成绩波动参数(标准差)
  71. mainExamUndulate: 0,
  72. quizExamUndulate: 0,
  73. //大小考每次考试平均成绩
  74. avgMain: 0,
  75. avgquiz: 0,
  76. }
  77. },
  78. onLoad() {
  79. this.getExamUndulate()
  80. },
  81. methods: {
  82. //成绩波动数据(标准差)
  83. getExamUndulate(){
  84. function arrSum(array) {
  85. let cont = 0
  86. for (let i = 0; i < array.length; i++) {
  87. cont += array[i]
  88. }
  89. return cont;
  90. }
  91. const mainArr = []
  92. const quizArr = []
  93. //统计每次考试总成绩并存为数组
  94. for (let item of this.examChartData.levelChartData[0].series) {
  95. mainArr.push(arrSum(item.data))
  96. }
  97. for (let item of this.examChartData.levelChartData[1].series) {
  98. quizArr.push(arrSum(item.data))
  99. }
  100. //大小考试平均成绩
  101. this.avgMain = arrSum(mainArr) / mainArr.length
  102. this.avgquiz = arrSum(quizArr) / quizArr.length
  103. //标准差函数
  104. function standardDeviation(arr) {
  105. let length = arr.length;
  106. let sum = arrSum(arr);
  107. let avg = sum / length;
  108. let temp = [];
  109. for (let i = 0; i < length; i++) {
  110. let dev = (arr[i]) - avg; //计算数组元素与平均值的差
  111. temp[i] = Math.pow(dev, 2); //计算差的平方
  112. }
  113. let powSum = arrSum(temp); //差的平方和
  114. let standardDeviation = parseFloat(Math.sqrt(powSum / length).toFixed(2)); //标准差
  115. return standardDeviation
  116. }
  117. this.mainExamUndulate = standardDeviation(mainArr)
  118. this.quizExamUndulate = standardDeviation(quizArr)
  119. },
  120. }
  121. }
  122. </script>
  123. <style lang="scss">
  124. @import 'gradelist_pages.scss';
  125. </style>