散点图.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. // 配置版本号
  2. const version = '2023092201'
  3. // 分类
  4. const category = '散点图'
  5. // 标题
  6. const title = '散点图'
  7. // 类别, new Line()
  8. const chartType = 'Scatter'
  9. // 用于标识,唯一,和文件夹名称一致
  10. const name = 'SanDianTu'
  11. // 右侧配置项
  12. const setting = [
  13. {
  14. label: '维度',
  15. type: 'select', // 设置组件类型
  16. field: 'size', // 字段
  17. optionField: 'size', // 对应options中的字段
  18. // 是否多选
  19. multiple: false,
  20. value: '',
  21. tabName: 'data'
  22. },
  23. {
  24. label: '指标',
  25. type: 'select', // 设置组件类型
  26. field: 'sets', // 字段
  27. optionField: 'sets', // 对应options中的字段
  28. // 是否多选
  29. multiple: false,
  30. value: '',
  31. tabName: 'data'
  32. },
  33. {
  34. label: '颜色',
  35. type: 'select', // 设置组件类型
  36. field: 'colorField', // 字段
  37. optionField: 'colorField', // 对应options中的字段
  38. // 是否多选
  39. multiple: false,
  40. value: '',
  41. tabName: 'data'
  42. },
  43. {
  44. label: '颜色配置',
  45. // 设置组件类型
  46. type: 'colorSelect',
  47. // 字段
  48. field: 'color',
  49. // 对应options中的字段
  50. optionField: 'color',
  51. value: ['#6b74e4', '#4391f4', '#38bbe5', '#69d6fd', '#36c6a0'],
  52. tabName: 'custom',
  53. groupName: 'graph'
  54. },
  55. {
  56. label: '数据点形状',
  57. type: 'select', // 设置组件类型
  58. field: 'shape', // 字段
  59. optionField: 'shape', // 对应options中的字段
  60. // 是否多选
  61. multiple: false,
  62. value: 'circle',
  63. tabName: 'custom',
  64. options: [
  65. {
  66. label: '无',
  67. value: false
  68. },
  69. {
  70. label: '空心圆',
  71. value: 'hollow-circle'
  72. },
  73. {
  74. label: '圆形',
  75. value: 'circle'
  76. },
  77. {
  78. label: '正方形',
  79. value: 'square'
  80. },
  81. {
  82. label: '菱形',
  83. value: 'diamond'
  84. },
  85. {
  86. label: '三角形',
  87. value: 'triangle'
  88. },
  89. {
  90. label: '六边形',
  91. value: 'hexagon'
  92. },
  93. {
  94. label: '菱形交叉',
  95. value: 'bowtie'
  96. },
  97. {
  98. label: '十字形',
  99. value: 'cross'
  100. },
  101. {
  102. label: 'I形',
  103. value: 'tick'
  104. },
  105. {
  106. label: '加号',
  107. value: 'plus'
  108. },
  109. {
  110. label: '连字号',
  111. value: 'hyphen'
  112. }
  113. ],
  114. groupName: 'graph'
  115. },
  116. {
  117. label: '透明度',
  118. type: 'inputNumber', // 设置组件类型
  119. field: 'pointStyle_fillOpacity', // 字段
  120. optionField: 'pointStyle.fillOpacity', // 对应options中的字段
  121. value: 0.8,
  122. tabName: 'custom',
  123. groupName: 'graph'
  124. },
  125. {
  126. label: '图表边距',
  127. type: 'padding', // 设置组件类型
  128. field: 'appendPadding', //
  129. optionField: 'appendPadding', // 对应options中的字段
  130. value: [20, 20, 20, 20],
  131. tabName: 'custom',
  132. groupName: 'padding'
  133. }
  134. ]
  135. // 模拟数据
  136. const data = [
  137. {
  138. Title: 'Guardians of the Galaxy',
  139. Genre: 'Action',
  140. 'Revenue (Millions)': 333.13,
  141. Rating: 8.1
  142. },
  143. {
  144. Title: 'Prometheus',
  145. Genre: 'Adventure',
  146. 'Revenue (Millions)': 126.46,
  147. Rating: 7
  148. },
  149. {
  150. Title: 'Split',
  151. Genre: 'Horror',
  152. 'Revenue (Millions)': 138.12,
  153. Rating: 7.3
  154. },
  155. {
  156. Title: 'Sing',
  157. Genre: 'Animation',
  158. 'Revenue (Millions)': 270.32,
  159. Rating: 7.2
  160. },
  161. {
  162. Title: 'Suicide Squad',
  163. Genre: 'Action',
  164. 'Revenue (Millions)': 325.02,
  165. Rating: 6.2
  166. },
  167. {
  168. Title: 'The Great Wall',
  169. Genre: 'Action',
  170. 'Revenue (Millions)': 45.13,
  171. Rating: 6.1
  172. },
  173. {
  174. Title: 'La La Land',
  175. Genre: 'Comedy',
  176. 'Revenue (Millions)': 151.06,
  177. Rating: 8.3
  178. },
  179. {
  180. Title: 'Mindhorn',
  181. Genre: 'Comedy',
  182. 'Revenue (Millions)': null,
  183. Rating: 6.4
  184. },
  185. {
  186. Title: 'The Lost City of Z',
  187. Genre: 'Action',
  188. 'Revenue (Millions)': 8.01,
  189. Rating: 7.1
  190. },
  191. {
  192. Title: 'Passengers',
  193. Genre: 'Adventure',
  194. 'Revenue (Millions)': 100.01,
  195. Rating: 7
  196. },
  197. {
  198. Title: 'Fantastic Beasts and Where to Find Them',
  199. Genre: 'Adventure',
  200. 'Revenue (Millions)': 234.02,
  201. Rating: 7.5
  202. },
  203. {
  204. Title: 'Hidden Figures',
  205. Genre: 'Other',
  206. 'Revenue (Millions)': 169.27,
  207. Rating: 7.8
  208. },
  209. {
  210. Title: 'Rogue One',
  211. Genre: 'Action',
  212. 'Revenue (Millions)': 532.17,
  213. Rating: 7.9
  214. },
  215. {
  216. Title: 'Moana',
  217. Genre: 'Animation',
  218. 'Revenue (Millions)': 248.75,
  219. Rating: 7.7
  220. },
  221. {
  222. Title: 'Colossal',
  223. Genre: 'Action',
  224. 'Revenue (Millions)': 2.87,
  225. Rating: 6.4
  226. },
  227. {
  228. Title: 'The Secret Life of Pets',
  229. Genre: 'Animation',
  230. 'Revenue (Millions)': 368.31,
  231. Rating: 6.6
  232. },
  233. {
  234. Title: 'Hacksaw Ridge',
  235. Genre: 'Other',
  236. 'Revenue (Millions)': 67.12,
  237. Rating: 8.2
  238. },
  239. {
  240. Title: 'Jason Bourne',
  241. Genre: 'Action',
  242. 'Revenue (Millions)': 162.16,
  243. Rating: 6.7
  244. },
  245. {
  246. Title: 'Lion',
  247. Genre: 'Other',
  248. 'Revenue (Millions)': 51.69,
  249. Rating: 8.1
  250. },
  251. {
  252. Title: 'Gold',
  253. Genre: 'Adventure',
  254. 'Revenue (Millions)': 7.22,
  255. Rating: 6.7
  256. }
  257. ]
  258. // 配置处理脚本
  259. const optionHandler = ''
  260. // 数据处理脚本
  261. const dataHandler = ''
  262. // 图表配置 new Line('domName', option)
  263. const option = {
  264. appendPadding: 10,
  265. data,
  266. xField: 'Revenue (Millions)',
  267. yField: 'Rating',
  268. colorField: 'Genre',
  269. shape: 'diamond',
  270. pointStyle: {
  271. fillOpacity: 0.8
  272. },
  273. color: ['#6b74e4', '#4391f4', '#38bbe5', '#69d6fd', '#36c6a0'],
  274. size: 4,
  275. yAxis: {
  276. nice: true,
  277. line: {
  278. style: {
  279. stroke: '#aaa'
  280. }
  281. }
  282. },
  283. xAxis: {
  284. min: -100,
  285. grid: {
  286. line: {
  287. style: {
  288. stroke: '#eee'
  289. }
  290. }
  291. },
  292. line: {
  293. style: {
  294. stroke: '#aaa'
  295. }
  296. }
  297. }
  298. }
  299. export default {
  300. version,
  301. category,
  302. title,
  303. chartType,
  304. name,
  305. option,
  306. setting,
  307. optionHandler,
  308. dataHandler
  309. }