echarts-data.ts 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. import { EChartsOption } from 'echarts'
  2. import { useI18n } from '@/hooks/web/useI18n'
  3. import { EChartsOption as EChartsWordOption } from 'echarts-wordcloud'
  4. const { t } = useI18n()
  5. export const lineOptions: EChartsOption = {
  6. title: {
  7. text: t('analysis.monthlySales'),
  8. left: 'center'
  9. },
  10. xAxis: {
  11. data: [
  12. t('analysis.january'),
  13. t('analysis.february'),
  14. t('analysis.march'),
  15. t('analysis.april'),
  16. t('analysis.may'),
  17. t('analysis.june'),
  18. t('analysis.july'),
  19. t('analysis.august'),
  20. t('analysis.september'),
  21. t('analysis.october'),
  22. t('analysis.november'),
  23. t('analysis.december')
  24. ],
  25. boundaryGap: false,
  26. axisTick: {
  27. show: false
  28. }
  29. },
  30. grid: {
  31. left: 20,
  32. right: 20,
  33. bottom: 20,
  34. top: 80,
  35. containLabel: true
  36. },
  37. tooltip: {
  38. trigger: 'axis',
  39. axisPointer: {
  40. type: 'cross'
  41. },
  42. padding: [5, 10]
  43. },
  44. yAxis: {
  45. axisTick: {
  46. show: false
  47. }
  48. },
  49. legend: {
  50. data: [t('analysis.estimate'), t('analysis.actual')],
  51. top: 50
  52. },
  53. series: [
  54. {
  55. name: t('analysis.estimate'),
  56. smooth: true,
  57. type: 'line',
  58. data: [100, 120, 161, 134, 105, 160, 165, 114, 163, 185, 118, 123],
  59. animationDuration: 2800,
  60. animationEasing: 'cubicInOut'
  61. },
  62. {
  63. name: t('analysis.actual'),
  64. smooth: true,
  65. type: 'line',
  66. itemStyle: {},
  67. data: [120, 82, 91, 154, 162, 140, 145, 250, 134, 56, 99, 123],
  68. animationDuration: 2800,
  69. animationEasing: 'quadraticOut'
  70. }
  71. ]
  72. }
  73. export const pieOptions: EChartsOption = {
  74. title: {
  75. text: t('analysis.userAccessSource'),
  76. left: 'center'
  77. },
  78. tooltip: {
  79. trigger: 'item',
  80. formatter: '{a} <br/>{b} : {c} ({d}%)'
  81. },
  82. legend: {
  83. orient: 'vertical',
  84. left: 'left',
  85. data: [
  86. t('analysis.directAccess'),
  87. t('analysis.mailMarketing'),
  88. t('analysis.allianceAdvertising'),
  89. t('analysis.videoAdvertising'),
  90. t('analysis.searchEngines')
  91. ]
  92. },
  93. series: [
  94. {
  95. name: t('analysis.userAccessSource'),
  96. type: 'pie',
  97. radius: '55%',
  98. center: ['50%', '60%'],
  99. data: [
  100. { value: 335, name: t('analysis.directAccess') },
  101. { value: 310, name: t('analysis.mailMarketing') },
  102. { value: 234, name: t('analysis.allianceAdvertising') },
  103. { value: 135, name: t('analysis.videoAdvertising') },
  104. { value: 1548, name: t('analysis.searchEngines') }
  105. ]
  106. }
  107. ]
  108. }
  109. export const barOptions: EChartsOption = {
  110. title: {
  111. text: t('analysis.weeklyUserActivity'),
  112. left: 'center'
  113. },
  114. tooltip: {
  115. trigger: 'axis',
  116. axisPointer: {
  117. type: 'shadow'
  118. }
  119. },
  120. grid: {
  121. left: 50,
  122. right: 20,
  123. bottom: 20
  124. },
  125. xAxis: {
  126. type: 'category',
  127. data: [
  128. t('analysis.monday'),
  129. t('analysis.tuesday'),
  130. t('analysis.wednesday'),
  131. t('analysis.thursday'),
  132. t('analysis.friday'),
  133. t('analysis.saturday'),
  134. t('analysis.sunday')
  135. ],
  136. axisTick: {
  137. alignWithLabel: true
  138. }
  139. },
  140. yAxis: {
  141. type: 'value'
  142. },
  143. series: [
  144. {
  145. name: t('analysis.activeQuantity'),
  146. data: [13253, 34235, 26321, 12340, 24643, 1322, 1324],
  147. type: 'bar'
  148. }
  149. ]
  150. }
  151. export const radarOption: EChartsOption = {
  152. legend: {
  153. data: [t('workplace.personal'), t('workplace.team')]
  154. },
  155. radar: {
  156. // shape: 'circle',
  157. indicator: [
  158. { name: t('workplace.quote'), max: 65 },
  159. { name: t('workplace.contribution'), max: 160 },
  160. { name: t('workplace.hot'), max: 300 },
  161. { name: t('workplace.yield'), max: 130 },
  162. { name: t('workplace.follow'), max: 100 }
  163. ]
  164. },
  165. series: [
  166. {
  167. name: `xxx${t('workplace.index')}`,
  168. type: 'radar',
  169. data: [
  170. {
  171. value: [42, 30, 20, 35, 80],
  172. name: t('workplace.personal')
  173. },
  174. {
  175. value: [50, 140, 290, 100, 90],
  176. name: t('workplace.team')
  177. }
  178. ]
  179. }
  180. ]
  181. }
  182. export const wordOptions: EChartsWordOption = {
  183. series: [
  184. {
  185. type: 'wordCloud',
  186. gridSize: 2,
  187. sizeRange: [12, 50],
  188. rotationRange: [-90, 90],
  189. shape: 'pentagon',
  190. width: 600,
  191. height: 400,
  192. drawOutOfBound: true,
  193. textStyle: {
  194. color: function () {
  195. return (
  196. 'rgb(' +
  197. [
  198. Math.round(Math.random() * 160),
  199. Math.round(Math.random() * 160),
  200. Math.round(Math.random() * 160)
  201. ].join(',') +
  202. ')'
  203. )
  204. }
  205. },
  206. emphasis: {
  207. textStyle: {
  208. shadowBlur: 10,
  209. shadowColor: '#333'
  210. }
  211. },
  212. data: [
  213. {
  214. name: 'Sam S Club',
  215. value: 10000,
  216. textStyle: {
  217. color: 'black'
  218. },
  219. emphasis: {
  220. textStyle: {
  221. color: 'red'
  222. }
  223. }
  224. },
  225. {
  226. name: 'Macys',
  227. value: 6181
  228. },
  229. {
  230. name: 'Amy Schumer',
  231. value: 4386
  232. },
  233. {
  234. name: 'Jurassic World',
  235. value: 4055
  236. },
  237. {
  238. name: 'Charter Communications',
  239. value: 2467
  240. },
  241. {
  242. name: 'Chick Fil A',
  243. value: 2244
  244. },
  245. {
  246. name: 'Planet Fitness',
  247. value: 1898
  248. },
  249. {
  250. name: 'Pitch Perfect',
  251. value: 1484
  252. },
  253. {
  254. name: 'Express',
  255. value: 1112
  256. },
  257. {
  258. name: 'Home',
  259. value: 965
  260. },
  261. {
  262. name: 'Johnny Depp',
  263. value: 847
  264. },
  265. {
  266. name: 'Lena Dunham',
  267. value: 582
  268. },
  269. {
  270. name: 'Lewis Hamilton',
  271. value: 555
  272. },
  273. {
  274. name: 'KXAN',
  275. value: 550
  276. },
  277. {
  278. name: 'Mary Ellen Mark',
  279. value: 462
  280. },
  281. {
  282. name: 'Farrah Abraham',
  283. value: 366
  284. },
  285. {
  286. name: 'Rita Ora',
  287. value: 360
  288. },
  289. {
  290. name: 'Serena Williams',
  291. value: 282
  292. },
  293. {
  294. name: 'NCAA baseball tournament',
  295. value: 273
  296. },
  297. {
  298. name: 'Point Break',
  299. value: 265
  300. }
  301. ]
  302. }
  303. ]
  304. }