_chart.ts 3.5 KB

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