level.vue 4.2 KB

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