2
0

_chart.ts 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. import { format } from 'date-fns';
  2. import * as Mock from 'mockjs';
  3. // region: mock data
  4. const visitData: any[] = [];
  5. const beginDay = new Date().getTime();
  6. const fakeY = [7, 5, 4, 2, 4, 7, 5, 6, 5, 9, 6, 3, 1, 5, 3, 6, 5];
  7. for (let i = 0; i < fakeY.length; i += 1) {
  8. visitData.push({
  9. x: format(new Date(beginDay + 1000 * 60 * 60 * 24 * i), 'yyyy-MM-dd'),
  10. y: fakeY[i]
  11. });
  12. }
  13. const visitData2: any[] = [];
  14. const fakeY2 = [1, 6, 4, 8, 3, 7, 2];
  15. for (let i = 0; i < fakeY2.length; i += 1) {
  16. visitData2.push({
  17. x: format(new Date(beginDay + 1000 * 60 * 60 * 24 * i), 'yyyy-MM-dd'),
  18. y: fakeY2[i]
  19. });
  20. }
  21. const salesData: any[] = [];
  22. for (let i = 0; i < 12; i += 1) {
  23. salesData.push({
  24. x: `${i + 1}月`,
  25. y: Math.floor(Math.random() * 1000) + 200
  26. });
  27. }
  28. const searchData: any[] = [];
  29. for (let i = 0; i < 50; i += 1) {
  30. searchData.push({
  31. index: i + 1,
  32. keyword: `搜索关键词-${i}`,
  33. count: Math.floor(Math.random() * 1000),
  34. range: Math.floor(Math.random() * 100),
  35. status: Math.floor((Math.random() * 10) % 2)
  36. });
  37. }
  38. const salesTypeData = [
  39. {
  40. x: '家用电器',
  41. y: 4544
  42. },
  43. {
  44. x: '食用酒水',
  45. y: 3321
  46. },
  47. {
  48. x: '个护健康',
  49. y: 3113
  50. },
  51. {
  52. x: '服饰箱包',
  53. y: 2341
  54. },
  55. {
  56. x: '母婴产品',
  57. y: 1231
  58. },
  59. {
  60. x: '其他',
  61. y: 1231
  62. }
  63. ];
  64. const salesTypeDataOnline = [
  65. {
  66. x: '家用电器',
  67. y: 244
  68. },
  69. {
  70. x: '食用酒水',
  71. y: 321
  72. },
  73. {
  74. x: '个护健康',
  75. y: 311
  76. },
  77. {
  78. x: '服饰箱包',
  79. y: 41
  80. },
  81. {
  82. x: '母婴产品',
  83. y: 121
  84. },
  85. {
  86. x: '其他',
  87. y: 111
  88. }
  89. ];
  90. const salesTypeDataOffline = [
  91. {
  92. x: '家用电器',
  93. y: 99
  94. },
  95. {
  96. x: '个护健康',
  97. y: 188
  98. },
  99. {
  100. x: '服饰箱包',
  101. y: 344
  102. },
  103. {
  104. x: '母婴产品',
  105. y: 255
  106. },
  107. {
  108. x: '其他',
  109. y: 65
  110. }
  111. ];
  112. const offlineData: any[] = [];
  113. for (let i = 0; i < 10; i += 1) {
  114. offlineData.push({
  115. name: `门店${i}`,
  116. cvr: Math.ceil(Math.random() * 9) / 10
  117. });
  118. }
  119. const offlineChartData: any[] = [];
  120. for (let i = 0; i < 20; i += 1) {
  121. offlineChartData.push({
  122. time: new Date().getTime() + 1000 * 60 * 30 * i,
  123. y1: Math.floor(Math.random() * 100) + 10,
  124. y2: Math.floor(Math.random() * 100) + 10
  125. });
  126. }
  127. const radarOriginData = [
  128. {
  129. name: '个人',
  130. ref: 10,
  131. koubei: 8,
  132. output: 4,
  133. contribute: 5,
  134. hot: 7
  135. },
  136. {
  137. name: '团队',
  138. ref: 3,
  139. koubei: 9,
  140. output: 6,
  141. contribute: 3,
  142. hot: 1
  143. },
  144. {
  145. name: '部门',
  146. ref: 4,
  147. koubei: 1,
  148. output: 6,
  149. contribute: 5,
  150. hot: 7
  151. }
  152. ];
  153. //
  154. const radarData: any[] = [];
  155. const radarTitleMap: any = {
  156. ref: '引用',
  157. koubei: '口碑',
  158. output: '产量',
  159. contribute: '贡献',
  160. hot: '热度'
  161. };
  162. radarOriginData.forEach((item: any) => {
  163. Object.keys(item).forEach(key => {
  164. if (key !== 'name') {
  165. radarData.push({
  166. name: item.name,
  167. label: radarTitleMap[key],
  168. value: item[key]
  169. });
  170. }
  171. });
  172. });
  173. // endregion
  174. export const CHARTS = {
  175. '/chart': JSON.parse(
  176. JSON.stringify({
  177. visitData,
  178. visitData2,
  179. salesData,
  180. searchData,
  181. offlineData,
  182. offlineChartData,
  183. salesTypeData,
  184. salesTypeDataOnline,
  185. salesTypeDataOffline,
  186. radarData
  187. })
  188. ),
  189. '/chart/visit': JSON.parse(JSON.stringify(visitData)),
  190. '/chart/tags': Mock.mock({
  191. 'list|100': [{ name: '@city', 'value|1-100': 150 }]
  192. })
  193. };