radar-chart.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <template>
  2. <view class="page-box">
  3. <back @click="returnList"></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">
  14. <view class="item-text">考试成绩波动对比:</view>
  15. <view class="item-number">{{mainExamUndulate>=quizExamUndulate?'小考稳定':'大考稳定'}}</view>
  16. <view style="display: flex;align-items: center;padding-bottom: 15rpx;padding: 0 15rpx 10rpx 15rpx;">
  17. <view v-if="mainExamUndulate>=quizExamUndulate" class="t-icon t-icon-jiangbei-4"></view>
  18. <view v-if="mainExamUndulate<quizExamUndulate" class="t-icon t-icon-jiangbei-3"></view>
  19. <view v-if="mainExamUndulate>=quizExamUndulate" class="icon-text-item">重要考试时沉住气稳住心态</view>
  20. <view v-if="mainExamUndulate<quizExamUndulate" class="icon-text-item">普通考试也不能掉以轻心</view>
  21. </view>
  22. </view>
  23. <view class="data-box-item2">
  24. <view class="item-text">考试得分能力对比:</view>
  25. <view class="item-number">{{avgMain>=avgquiz?'大考能力强':'小考能力强'}}</view>
  26. <view style="display: flex;align-items: center;padding-bottom: 15rpx;padding: 0 15rpx 10rpx 15rpx;">
  27. <view v-if="avgMain<avgquiz" class="t-icon t-icon-jiangbei-4"></view>
  28. <view v-if="avgMain>=avgquiz" class="t-icon t-icon-jiangbei-3"></view>
  29. <view v-if="avgMain<avgquiz" class="icon-text-item">重要考试要多证明自己能力</view>
  30. <view v-if="avgMain>=avgquiz" class="icon-text-item">普通考试要注重得分与练习</view>
  31. </view>
  32. </view>
  33. </view>
  34. <!-- 图表列表 -->
  35. <view class="chart-container">
  36. <view class="chart-name">
  37. <view class="t-icon t-icon-xianxingsakesi"></view>
  38. <text class="chart-name-text">重要考试对比</text>
  39. </view>
  40. <!-- 图表 -->
  41. <view class="charts-box">
  42. <qiun-data-charts type="radar" :chartData="gradeData.abilityRadarChart.importantAnalyse"
  43. :loadingType="4" :canvas2d='true' canvasId='canvans8312399'/>
  44. </view>
  45. </view>
  46. <view class="chart-container">
  47. <view class="chart-name">
  48. <view class="t-icon t-icon-xianxingtouzi"></view>
  49. <text class="chart-name-text">普通测验记录</text>
  50. </view>
  51. <!-- 图表 -->
  52. <view class="charts-box">
  53. <qiun-data-charts type="radar" :chartData="gradeData.abilityRadarChart.commonAnalyse"
  54. :loadingType="4" :canvas2d='true' canvasId='canvans89139'/>
  55. </view>
  56. </view>
  57. </view>
  58. </template>
  59. <script>
  60. import {
  61. mapState
  62. } from 'vuex'
  63. export default {
  64. computed: {
  65. ...mapState('m_children', ['childreninfo', 'semester']),
  66. ...mapState('m_chart', ['gradeData'])
  67. },
  68. data() {
  69. return {
  70. //查询参数
  71. queryObj: {},
  72. //成绩波动参数(标准差)
  73. mainExamUndulate: 0,
  74. quizExamUndulate: 0,
  75. //大小考每次考试平均成绩
  76. avgMain: 0,
  77. avgquiz: 0,
  78. };
  79. },
  80. methods: {
  81. confirm(e) {
  82. console.log('confirm', e)
  83. uni.$showMsg('切换完成')
  84. this.show = false
  85. },
  86. //返回成绩页面
  87. returnList() {
  88. uni.switchTab({
  89. url: '/pages/grade/grade'
  90. })
  91. },
  92. //成绩波动数据(标准差)
  93. getExamUndulate() {
  94. //求和函数封装
  95. function arrSum(array) {
  96. let cont = 0
  97. for (let i = 0; i < array.length; i++) {
  98. cont += array[i]
  99. }
  100. return cont;
  101. }
  102. const mainArr = []
  103. const quizArr = []
  104. //统计每次考试总成绩并存为数组
  105. for (let item of this.gradeData.abilityRadarChart.importantAnalyse.series) {
  106. mainArr.push(arrSum(item.data))
  107. }
  108. for (let item of this.gradeData.abilityRadarChart.commonAnalyse.series) {
  109. quizArr.push(arrSum(item.data))
  110. }
  111. //大小考试平均成绩
  112. this.avgMain = arrSum(mainArr) / mainArr.length
  113. this.avgquiz = arrSum(quizArr) / quizArr.length
  114. console.log(this.avgMain, this.avgquiz);
  115. //标准差函数
  116. function standardDeviation(arr) {
  117. let length = arr.length;
  118. let sum = arrSum(arr);
  119. let avg = sum / length;
  120. let temp = [];
  121. for (let i = 0; i < length; i++) {
  122. let dev = (arr[i]) - avg; //计算数组元素与平均值的差
  123. temp[i] = Math.pow(dev, 2); //计算差的平方
  124. }
  125. let powSum = arrSum(temp); //差的平方和
  126. let standardDeviation = parseFloat(Math.sqrt(powSum / length).toFixed(2)); //标准差
  127. return standardDeviation
  128. }
  129. this.mainExamUndulate = standardDeviation(mainArr)
  130. this.quizExamUndulate = standardDeviation(quizArr)
  131. console.log(this.mainExamUndulate);
  132. console.log(this.quizExamUndulate);
  133. },
  134. },
  135. onLoad() {
  136. this.getExamUndulate()
  137. }
  138. }
  139. </script>
  140. <style lang="scss">
  141. @import '@/gradepkg/common/chartpage.scss';
  142. .page-box {
  143. background: linear-gradient(#ff8caf, $page-background-color);
  144. }
  145. .data-box {
  146. display: flex;
  147. flex-direction: row;
  148. align-items: center;
  149. flex-wrap: wrap;
  150. justify-content: space-between;
  151. margin: 40rpx 20rpx 20rpx 20rpx;
  152. .data-box-item2 {
  153. display: flex;
  154. flex-direction: column;
  155. background-color: #ff5959;
  156. border-radius: 15rpx;
  157. width: 340rpx;
  158. height: 290rpx;
  159. box-shadow: 0 4rpx 8rpx rgba(0, 0, 0, 0.1);
  160. .item-text {
  161. font-size: 30rpx;
  162. font-weight: bold;
  163. color: #FFFFFF;
  164. margin: 30rpx 0 0 30rpx;
  165. }
  166. .t-icon {
  167. width: 180rpx;
  168. height: 100rpx;
  169. }
  170. .item-number {
  171. font-size: 60rpx;
  172. margin: 10rpx 0 10rpx 25rpx;
  173. color: #FFFFFF;
  174. font-weight: bold;
  175. }
  176. }
  177. .data-box-item {
  178. display: flex;
  179. flex-direction: column;
  180. background-color: #0052d4;
  181. border-radius: 15rpx;
  182. width: 340rpx;
  183. height: 290rpx;
  184. box-shadow: 0 4rpx 8rpx rgba(0, 0, 0, 0.1);
  185. .item-text {
  186. font-size: 30rpx;
  187. font-weight: bold;
  188. color: #FFFFFF;
  189. margin: 30rpx 0 0 30rpx;
  190. }
  191. .t-icon {
  192. width: 180rpx;
  193. height: 100rpx;
  194. }
  195. .item-number {
  196. font-size: 60rpx;
  197. margin: 10rpx 0 10rpx 25rpx;
  198. color: #FFFFFF;
  199. font-weight: bold;
  200. }
  201. }
  202. }
  203. .icon-text-item {
  204. font-size: 30rpx;
  205. font-weight: bold;
  206. color: #FFFFFF;
  207. margin-left: 10rpx;
  208. }
  209. </style>