ability-chart.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <view class="page-box">
  3. <back text="考试能力"></back>
  4. <view class="children-box">
  5. <image class="children-avatar" :src="childreninfo.avatar"></image>
  6. <view class="children-msg">
  7. <view class="children-name">{{childreninfo.name}}</view>
  8. <view class="children-class">{{childreninfo.class}}</view>
  9. </view>
  10. </view>
  11. <!-- 数据分析模块 -->
  12. <view class="data-box">
  13. <view class="data-box-item" style="background-color: #4169E1;">
  14. <view class="item-text">成绩波动对比:</view>
  15. <view style="display: flex;align-items: baseline;">
  16. <view class="item-text" style="font-size: 50rpx;">{{mainExamUndulate>=quizExamUndulate?'小考':'大考'}}</view>
  17. <view class="item-text" style="margin-left: 0;">发挥稳定</view>
  18. </view>
  19. <view class="module-item-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="data-box-item" style="background-color: #ff8caf;">
  25. <view class="item-text">得分能力对比:</view>
  26. <view style="display: flex;align-items: baseline;">
  27. <view class="item-text" style="font-size: 50rpx;">{{avgMain>=avgquiz?'大考':'小考'}}</view>
  28. <view class="item-text" style="margin-left: 0;">得分能力强</view>
  29. </view>
  30. <view class="module-item-box">
  31. <view v-if="avgMain<avgquiz" class="t-icon t-icon-a-bianzu7"></view>
  32. <view v-if="avgMain>=avgquiz" class="t-icon t-icon-a-bianzu6"></view>
  33. </view>
  34. </view>
  35. </view>
  36. <!-- 图表列表 -->
  37. <view class="chart-container">
  38. <view class="chart-name">
  39. <view class="start-tag"></view>
  40. <text class="chart-name-text">重要考试对比</text>
  41. </view>
  42. <!-- 图表 -->
  43. <view class="charts-box">
  44. <qiun-data-charts type="column" :chartData="gradeData.abilityChart.importantAnalyse"
  45. :loadingType="4" tooltipFormat='tooltipScoreShort' :canvas2d="true" canvasId="canvasId876898"/>
  46. </view>
  47. </view>
  48. <view class="chart-container">
  49. <view class="chart-name">
  50. <view class="start-tag"></view>
  51. <text class="chart-name-text">普通测验记录</text>
  52. </view>
  53. <!-- 图表 -->
  54. <view class="charts-box">
  55. <qiun-data-charts type="column" :chartData="gradeData.abilityChart.commonAnalyse" :loadingType="4"
  56. tooltipFormat='tooltipScoreShort' :canvas2d="true" canvasId="canvasId931238"/>
  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_children', ['childreninfo', 'semester']),
  68. ...mapState('m_chart', ['gradeData'])
  69. },
  70. data() {
  71. return {
  72. //查询参数
  73. queryObj: {},
  74. //成绩波动参数(标准差)
  75. mainExamUndulate: 0,
  76. quizExamUndulate: 0,
  77. //大小考每次考试平均成绩
  78. avgMain: 0,
  79. avgquiz: 0,
  80. };
  81. },
  82. methods: {
  83. //成绩波动数据(标准差)
  84. getExamUndulate() {
  85. //求和函数封装
  86. function arrSum(array) {
  87. let cont = 0
  88. for (let i = 0; i < array.length; i++) {
  89. cont += array[i]
  90. }
  91. return cont;
  92. }
  93. const mainArr = []
  94. const quizArr = []
  95. //统计每次考试总成绩并存为数组
  96. for (let item of this.gradeData.abilityChart.importantAnalyse.series) {
  97. mainArr.push(arrSum(item.data))
  98. }
  99. for (let item of this.gradeData.abilityChart.commonAnalyse.series) {
  100. quizArr.push(arrSum(item.data))
  101. }
  102. //大小考试平均成绩
  103. this.avgMain = arrSum(mainArr) / mainArr.length
  104. this.avgquiz = arrSum(quizArr) / quizArr.length
  105. //标准差函数
  106. function standardDeviation(arr) {
  107. let length = arr.length;
  108. let sum = arrSum(arr);
  109. let avg = sum / length;
  110. let temp = [];
  111. for (let i = 0; i < length; i++) {
  112. let dev = (arr[i]) - avg; //计算数组元素与平均值的差
  113. temp[i] = Math.pow(dev, 2); //计算差的平方
  114. }
  115. let powSum = arrSum(temp); //差的平方和
  116. let standardDeviation = parseFloat(Math.sqrt(powSum / length).toFixed(2)); //标准差
  117. return standardDeviation
  118. }
  119. this.mainExamUndulate = standardDeviation(mainArr)
  120. this.quizExamUndulate = standardDeviation(quizArr)
  121. },
  122. },
  123. onLoad() {
  124. this.getExamUndulate()
  125. }
  126. }
  127. </script>
  128. <style lang="scss">
  129. @import '@/gradepkg/common/chartpage.scss';
  130. </style>