chart.js 2.8 KB

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