chart.js 3.1 KB

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