page.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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. const lineOption = {
  8. title: {
  9. text: '每题用时情况',
  10. textStyle: { fontSize: 24, fontWeight: 'normal', color: '#5e677b' },
  11. },
  12. tooltip: {
  13. trigger: 'axis',
  14. },
  15. legend: {
  16. data: ['我的', '全站'],
  17. right: 20,
  18. orient: 'vertical',
  19. },
  20. xAxis: {
  21. type: 'category',
  22. },
  23. yAxis: {
  24. type: 'value',
  25. min: 0,
  26. },
  27. dataset: {
  28. source: [['type', '我的', '全站'], ['1', 43.3, 85.8], ['2', 43.1, 73.4], ['3', 56.4, 65.2]],
  29. },
  30. series: [
  31. {
  32. type: 'line',
  33. smooth: true,
  34. color: '#8684df',
  35. },
  36. {
  37. type: 'line',
  38. smooth: true,
  39. color: '#5195e5',
  40. },
  41. ],
  42. };
  43. const barOption = {
  44. title: {
  45. text: '正确率',
  46. textStyle: { fontSize: 24, fontWeight: 'normal', color: '#5e677b' },
  47. },
  48. tooltip: {
  49. trigger: 'axis',
  50. },
  51. legend: {
  52. data: ['我的', '全站'],
  53. right: 20,
  54. orient: 'vertical',
  55. },
  56. dataset: {
  57. source: [['type', '我的', '全站'], ['Easy', 43.3, 85.8], ['Medium', 43.1, 73.4], ['Hard', 56.4, 65.2]],
  58. },
  59. xAxis: { type: 'category', boundaryGap: true },
  60. yAxis: {
  61. min: 0,
  62. max: 100,
  63. },
  64. series: [{ type: 'bar', barWidth: 40, color: '#8684df' }, { type: 'bar', barWidth: 40, color: '#5195e5' }],
  65. };
  66. const bar1Option = {
  67. title: {
  68. text: '用时',
  69. textStyle: { fontSize: 24, fontWeight: 'normal', color: '#5e677b' },
  70. },
  71. dataset: {
  72. source: [['type', 'text'], ['Avg Time Total', 43.3], ['Avg Time Correct', 43.1], ['Avg Time Incorrect', 56.4]],
  73. },
  74. xAxis: { type: 'category', axisTick: { show: false }, axisLine: { show: false }, splitLine: { show: false } },
  75. yAxis: {
  76. show: false,
  77. min: 0,
  78. max: 100,
  79. axisTick: { show: false },
  80. axisLine: { show: false },
  81. splitLine: { show: false },
  82. },
  83. series: [{ type: 'bar', barWidth: 40, color: '#8684df' }],
  84. };
  85. const bar2Option = {
  86. title: {
  87. text: '正确率',
  88. textStyle: { fontSize: 18, fontWeight: 'normal', color: '#5e677b' },
  89. left: 240,
  90. },
  91. dataset: {
  92. source: [['type', '我的'], ['Avg Time Total', 43.3], ['Avg Time Correct', 43.1], ['Avg Time Incorrect', 56.4]],
  93. },
  94. grid: { left: 240 },
  95. xAxis: {
  96. show: false,
  97. axisTick: { show: false },
  98. axisLine: { show: false },
  99. splitLine: { show: false },
  100. },
  101. yAxis: {
  102. type: 'category',
  103. show: true,
  104. axisTick: { show: false },
  105. axisLine: { show: false },
  106. splitLine: { show: false },
  107. axisLabel: { fontSize: 18, fontWeight: 'normal', color: '#5e677b' },
  108. offset: 36,
  109. },
  110. series: [
  111. {
  112. type: 'bar',
  113. barWidth: 40,
  114. color: '#8684df',
  115. label: {
  116. normal: {
  117. show: true,
  118. position: 'insideLeft',
  119. distance: 15,
  120. },
  121. },
  122. },
  123. ],
  124. };
  125. const bar3Option = {
  126. title: {
  127. text: '平均用时',
  128. textStyle: { fontSize: 18, fontWeight: 'normal', color: '#5e677b' },
  129. left: '10%',
  130. },
  131. dataset: {
  132. source: [['type', '我的'], ['Avg Time Total', 43.3], ['Avg Time Correct', 43.1], ['Avg Time Incorrect', 56.4]],
  133. },
  134. xAxis: {
  135. show: false,
  136. axisTick: { show: false },
  137. axisLine: { show: false },
  138. splitLine: { show: false },
  139. },
  140. yAxis: {
  141. type: 'category',
  142. show: true,
  143. axisTick: { show: false },
  144. axisLine: { show: false },
  145. splitLine: { show: false },
  146. axisLabel: { show: false },
  147. },
  148. series: [
  149. {
  150. type: 'bar',
  151. barWidth: 40,
  152. color: '#8684df',
  153. label: {
  154. normal: {
  155. show: true,
  156. position: 'insideLeft',
  157. distance: 15,
  158. },
  159. },
  160. },
  161. ],
  162. };
  163. const pieOption = {
  164. visualMap: {
  165. show: false,
  166. min: 0,
  167. max: 800,
  168. inRange: {
  169. colorLightness: [1, 0],
  170. },
  171. },
  172. series: [
  173. {
  174. name: '访问来源',
  175. type: 'pie',
  176. radius: '55%',
  177. center: ['50%', '50%'],
  178. roseType: 'radius',
  179. label: {
  180. normal: {
  181. fontSize: 18,
  182. position: 'inside',
  183. },
  184. },
  185. itemStyle: {
  186. normal: {
  187. color: '#5195e5',
  188. shadowBlur: 40,
  189. shadowColor: 'rgba(0, 0, 0, 0.2)',
  190. },
  191. },
  192. animationType: 'scale',
  193. animationEasing: 'elasticOut',
  194. animationDelay: () => {
  195. return Math.random() * 200;
  196. },
  197. data: [{ value: 335, name: '直接访问' }, { value: 310, name: '邮件营销' }, { value: 274, name: '联盟广告' }].sort(
  198. (a, b) => {
  199. return a.value - b.value;
  200. },
  201. ),
  202. },
  203. ],
  204. };
  205. export default class extends Page {
  206. renderView() {
  207. return (
  208. <div>
  209. <div className="content">
  210. <LineChart option={lineOption} />
  211. <BarChart option={bar1Option} />
  212. <BarChart option={bar2Option} />
  213. <BarChart option={bar3Option} />
  214. <BarChart option={barOption} />
  215. <PieChart option={pieOption} />
  216. </div>
  217. </div>
  218. );
  219. }
  220. }