page.js 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. import React from 'react';
  2. import './index.less';
  3. import LineChart from '@src/components/LineChart';
  4. import BarChart from '@src/components/BarChart';
  5. import PieChart from '@src/components/PieChart';
  6. import Page from '@src/containers/Page';
  7. import { Question } from '../../../stores/question';
  8. const lineOption = {
  9. title: {
  10. text: '每题用时情况',
  11. textStyle: { fontSize: 24, fontWeight: 'normal', color: '#5e677b' },
  12. },
  13. tooltip: {
  14. trigger: 'axis',
  15. },
  16. legend: {
  17. data: ['我的', '全站'],
  18. right: 20,
  19. orient: 'vertical',
  20. },
  21. xAxis: {
  22. type: 'category',
  23. },
  24. yAxis: {
  25. type: 'value',
  26. min: 0,
  27. },
  28. dataset: {
  29. source: [['type', '我的', '全站'], ['1', 43.3, 85.8], ['2', 43.1, 73.4], ['3', 56.4, 65.2]],
  30. },
  31. series: [
  32. {
  33. type: 'line',
  34. smooth: true,
  35. color: '#8684df',
  36. },
  37. {
  38. type: 'line',
  39. smooth: true,
  40. color: '#5195e5',
  41. },
  42. ],
  43. };
  44. const barOption = {
  45. title: {
  46. text: '正确率',
  47. textStyle: { fontSize: 24, fontWeight: 'normal', color: '#5e677b' },
  48. },
  49. tooltip: {
  50. trigger: 'axis',
  51. },
  52. legend: {
  53. data: ['我的', '全站'],
  54. right: 20,
  55. orient: 'vertical',
  56. },
  57. dataset: {
  58. source: [['type', '我的', '全站'], ['Easy', 43.3, 85.8], ['Medium', 43.1, 73.4], ['Hard', 56.4, 65.2]],
  59. },
  60. xAxis: { type: 'category', boundaryGap: true },
  61. yAxis: {
  62. min: 0,
  63. max: 100,
  64. },
  65. series: [{ type: 'bar', barWidth: 40, color: '#8684df' }, { type: 'bar', barWidth: 40, color: '#5195e5' }],
  66. };
  67. const bar1Option = {
  68. title: {
  69. text: '用时',
  70. textStyle: { fontSize: 24, fontWeight: 'normal', color: '#5e677b' },
  71. },
  72. dataset: {
  73. source: [['type', 'text'], ['Avg Time Total', 43.3], ['Avg Time Correct', 43.1], ['Avg Time Incorrect', 56.4]],
  74. },
  75. xAxis: { type: 'category', axisTick: { show: false }, axisLine: { show: false }, splitLine: { show: false } },
  76. yAxis: {
  77. show: false,
  78. min: 0,
  79. max: 100,
  80. axisTick: { show: false },
  81. axisLine: { show: false },
  82. splitLine: { show: false },
  83. },
  84. series: [{ type: 'bar', barWidth: 40, color: '#8684df' }],
  85. };
  86. const bar2Option = {
  87. title: {
  88. text: '正确率',
  89. textStyle: { fontSize: 18, fontWeight: 'normal', color: '#5e677b' },
  90. left: 240,
  91. },
  92. dataset: {
  93. source: [['type', '我的'], ['Avg Time Total', 43.3], ['Avg Time Correct', 43.1], ['Avg Time Incorrect', 56.4]],
  94. },
  95. grid: { left: 240 },
  96. xAxis: {
  97. show: false,
  98. axisTick: { show: false },
  99. axisLine: { show: false },
  100. splitLine: { show: false },
  101. },
  102. yAxis: {
  103. type: 'category',
  104. show: true,
  105. axisTick: { show: false },
  106. axisLine: { show: false },
  107. splitLine: { show: false },
  108. axisLabel: { fontSize: 18, fontWeight: 'normal', color: '#5e677b' },
  109. offset: 36,
  110. },
  111. series: [
  112. {
  113. type: 'bar',
  114. barWidth: 40,
  115. color: '#8684df',
  116. label: {
  117. normal: {
  118. show: true,
  119. position: 'insideLeft',
  120. distance: 15,
  121. },
  122. },
  123. },
  124. ],
  125. };
  126. const bar3Option = {
  127. title: {
  128. text: '平均用时',
  129. textStyle: { fontSize: 18, fontWeight: 'normal', color: '#5e677b' },
  130. left: '10%',
  131. },
  132. dataset: {
  133. source: [['type', '我的'], ['Avg Time Total', 43.3], ['Avg Time Correct', 43.1], ['Avg Time Incorrect', 56.4]],
  134. },
  135. xAxis: {
  136. show: false,
  137. axisTick: { show: false },
  138. axisLine: { show: false },
  139. splitLine: { show: false },
  140. },
  141. yAxis: {
  142. type: 'category',
  143. show: true,
  144. axisTick: { show: false },
  145. axisLine: { show: false },
  146. splitLine: { show: false },
  147. axisLabel: { show: false },
  148. },
  149. series: [
  150. {
  151. type: 'bar',
  152. barWidth: 40,
  153. color: '#8684df',
  154. label: {
  155. normal: {
  156. show: true,
  157. position: 'insideLeft',
  158. distance: 15,
  159. },
  160. },
  161. },
  162. ],
  163. };
  164. const pieOption = {
  165. visualMap: {
  166. show: false,
  167. min: 0,
  168. max: 800,
  169. inRange: {
  170. colorLightness: [1, 0],
  171. },
  172. },
  173. series: [
  174. {
  175. name: '访问来源',
  176. type: 'pie',
  177. radius: '55%',
  178. center: ['50%', '50%'],
  179. roseType: 'radius',
  180. label: {
  181. normal: {
  182. fontSize: 18,
  183. position: 'inside',
  184. },
  185. },
  186. itemStyle: {
  187. normal: {
  188. color: '#5195e5',
  189. shadowBlur: 40,
  190. shadowColor: 'rgba(0, 0, 0, 0.2)',
  191. },
  192. },
  193. animationType: 'scale',
  194. animationEasing: 'elasticOut',
  195. animationDelay: () => {
  196. return Math.random() * 200;
  197. },
  198. data: [{ value: 335, name: '直接访问' }, { value: 310, name: '邮件营销' }, { value: 274, name: '联盟广告' }].sort(
  199. (a, b) => {
  200. return a.value - b.value;
  201. },
  202. ),
  203. },
  204. ],
  205. };
  206. export default class extends Page {
  207. initState() {
  208. return { report: { paperModule: 'exercise' } };
  209. }
  210. initData() {
  211. const { id } = this.params;
  212. const { page = '' } = this.state.search;
  213. Question.detailReport(id).then(result => {
  214. switch (result.paperModule) {
  215. case 'sentence':
  216. this.refreshSentence(result);
  217. break;
  218. case 'textbook':
  219. this.refreshTextbook(result);
  220. break;
  221. case 'exercise':
  222. this.refreshExercise(result);
  223. break;
  224. case 'examination':
  225. this.refreshExamination(result);
  226. break;
  227. default:
  228. }
  229. this.setState({ report: result });
  230. });
  231. switch (page) {
  232. case 'question':
  233. // 题目回顾列表
  234. Question.questionReport(id).then(result => {
  235. this.setState({ list: result });
  236. });
  237. break;
  238. default:
  239. break;
  240. }
  241. }
  242. refreshSentence() {
  243. const { page = '' } = this.state.search;
  244. switch (page) {
  245. case 'question':
  246. break;
  247. default:
  248. }
  249. }
  250. refreshTextbook() {
  251. this.refreshExercise();
  252. }
  253. refreshExamination() {
  254. const { page = '' } = this.state.search;
  255. switch (page) {
  256. case 'total':
  257. break;
  258. case 'question':
  259. break;
  260. default:
  261. }
  262. }
  263. refreshExercise() {
  264. const { page = '' } = this.state.search;
  265. switch (page) {
  266. case 'question':
  267. break;
  268. default:
  269. }
  270. }
  271. renderView() {
  272. const { report = {} } = this.state;
  273. switch (report.paperModule) {
  274. case 'sentence':
  275. return this.renderSentence();
  276. case 'textbook':
  277. return this.renderTextbook();
  278. case 'exercise':
  279. return this.renderExercise();
  280. case 'examination':
  281. return this.renderExamination();
  282. default:
  283. return <div />;
  284. }
  285. }
  286. renderSentence() {
  287. return <div />;
  288. }
  289. renderTextbook() {
  290. return this.renderExercise();
  291. }
  292. renderExercise() {
  293. return <div>
  294. <div className="content">
  295. <LineChart option={lineOption} />
  296. <BarChart option={bar1Option} />
  297. <BarChart option={bar2Option} />
  298. <BarChart option={bar3Option} />
  299. <BarChart option={barOption} />
  300. <PieChart option={pieOption} />
  301. </div>
  302. </div>;
  303. }
  304. renderExamination() {
  305. return <div />;
  306. }
  307. }