多折线动画图.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  1. /*
  2. * @description: 配置,参考https://g2plot.antv.antgroup.com/examples
  3. * @Date: 2023-03-27 14:38:23
  4. * @Author: xing.heng
  5. */
  6. // 配置版本号
  7. const version = '0.0.1'
  8. // 分类
  9. const category = 'Line'
  10. // 标题
  11. const title = '多折线动画图'
  12. // 类别, new Line()
  13. const chartType = 'Line'
  14. // 用于标识,唯一,title的中文转拼音
  15. const name = 'DuoZheXianDongHuaTu'
  16. // 右侧配置项
  17. const setting = [
  18. {
  19. label: '维度',
  20. // 设置组件类型, select / input / colorPicker
  21. type: 'select',
  22. // 字段
  23. field: 'xField',
  24. optionField: 'xField', // 对应options中的字段
  25. // 是否多选
  26. multiple: false,
  27. // 绑定的值
  28. value: '',
  29. // tab页。 data: 数据, custom: 自定义
  30. tabName: 'data'
  31. },
  32. {
  33. label: '指标',
  34. // 设置组件类型
  35. type: 'select',
  36. // 字段
  37. field: 'yField',
  38. // 对应options中的字段
  39. optionField: 'yField',
  40. // 是否多选
  41. multiple: false,
  42. value: '',
  43. tabName: 'data'
  44. },
  45. {
  46. label: '分组',
  47. // 设置组件类型
  48. type: 'select',
  49. // 字段
  50. field: 'seriesField',
  51. // 对应options中的字段
  52. optionField: 'seriesField',
  53. // 是否多选
  54. multiple: false,
  55. value: '',
  56. tabName: 'data'
  57. },
  58. /** 样式配置 **/
  59. // 图表 graph
  60. {
  61. label: '折线宽度',
  62. type: 'inputNumber',
  63. field: 'lineStyle_lineWidth',
  64. optionField: 'lineStyle.lineWidth',
  65. value: 2,
  66. tabName: 'custom',
  67. groupName: 'graph'
  68. },
  69. {
  70. label: '折线颜色',
  71. // 设置组件类型
  72. type: 'colorSelect',
  73. // 字段
  74. field: 'color',
  75. // 对应options中的字段
  76. optionField: 'color',
  77. value: ['#5B8FF9', '#61DDAA', '#5D7092', '#F6BD16', '#6F5EF9', '#6DC8EC', '#945FB9', '#FF9845', '#1E9493', '#FF99C3'],
  78. tabName: 'custom',
  79. groupName: 'graph'
  80. },
  81. {
  82. label: '动画效果',
  83. // 设置组件类型
  84. type: 'select',
  85. // 字段
  86. field: 'animation_appear_animation',
  87. // 对应options中的字段
  88. optionField: 'animation.appear.animation',
  89. // 是否多选
  90. multiple: false,
  91. value: 'path-in',
  92. tabName: 'custom',
  93. options: [
  94. { label: '渐现动画', value: 'fade-in' },
  95. { label: '渐隐动画', value: 'fade-out' },
  96. { label: '容器沿着 x,y 方向放大的矩阵动画', value: 'grow-in-xy' },
  97. { label: '划入入场动画效果', value: 'wave-in' },
  98. { label: '沿着图形中心点的放大动画', value: 'zoom-in' },
  99. { label: '沿着图形中心点的缩小动画', value: 'zoom-out' },
  100. { label: 'path 路径入场动画', value: 'path-in' }
  101. ],
  102. groupName: 'graph'
  103. },
  104. {
  105. label: '动画时长(ms)',
  106. // 设置组件类型
  107. type: 'inputNumber',
  108. // 字段
  109. field: 'animation_appear_duration',
  110. // 对应options中的字段
  111. optionField: 'animation.appear.duration',
  112. value: 5000,
  113. max: 10000,
  114. tabName: 'custom',
  115. groupName: 'graph'
  116. },
  117. // 网格线 grid
  118. {
  119. label: '虚线',
  120. type: 'switchCustom',
  121. field: 'yAxis_grid_line_style_lineDash',
  122. optionField: 'yAxis.grid.line.style.lineDash',
  123. value: 0,
  124. active: 5,
  125. inactive: 0,
  126. tabName: 'custom',
  127. groupName: 'grid'
  128. },
  129. {
  130. label: '宽度',
  131. type: 'inputNumber',
  132. field: 'yAxis_grid_line_style_lineWidth',
  133. optionField: 'yAxis.grid.line.style.lineWidth',
  134. value: 1,
  135. tabName: 'custom',
  136. groupName: 'grid'
  137. },
  138. {
  139. label: '颜色',
  140. type: 'colorPicker',
  141. field: 'yAxis_grid_line_style_stroke',
  142. optionField: 'yAxis.grid.line.style.stroke',
  143. value: '#d0d0d0',
  144. tabName: 'custom',
  145. groupName: 'grid'
  146. },
  147. // 图例 legend
  148. {
  149. label: '显示',
  150. type: 'switch', // 设置组件类型
  151. field: 'legendEnable', // 字段
  152. optionField: 'legendEnable', // 对应options中的字段
  153. value: false,
  154. tabName: 'custom',
  155. groupName: 'legend'
  156. },
  157. {
  158. label: '位置',
  159. type: 'select', // 设置组件类型
  160. field: 'legendPosition', // 字段
  161. optionField: 'legendPosition', // 对应options中的字段
  162. // 是否多选
  163. multiple: false,
  164. value: 'top',
  165. tabName: 'custom',
  166. options: [
  167. { label: '顶部', value: 'top' },
  168. { label: '左上角', value: 'top-left' },
  169. { label: '右上角', value: 'top-right' },
  170. { label: '左侧', value: 'left' },
  171. // { label: '左上方', value: 'left-top' },
  172. // { label: '左下方', value: 'left-bottom' },
  173. { label: '右侧', value: 'right' },
  174. // { label: '右上方', value: 'right-top' },
  175. // { label: '右下方', value: 'right-bottom' },
  176. { label: '底部', value: 'bottom' },
  177. { label: '左下角', value: 'bottom-left' },
  178. { label: '右下角', value: 'bottom-right' }
  179. ],
  180. groupName: 'legend'
  181. },
  182. {
  183. label: '字体大小',
  184. type: 'inputNumber',
  185. field: 'legendItemName_style_fontSize',
  186. optionField: 'legendItemName.style.fontSize',
  187. value: 12,
  188. tabName: 'custom',
  189. groupName: 'legend'
  190. },
  191. {
  192. label: '字体权重',
  193. type: 'inputNumber',
  194. step: 100,
  195. max: 900,
  196. field: 'legendItemName_style_fontWeight',
  197. optionField: 'legendItemName.style.fontWeight',
  198. value: 400,
  199. tabName: 'custom',
  200. groupName: 'legend'
  201. },
  202. {
  203. label: '字体颜色',
  204. type: 'colorPicker',
  205. field: 'legendItemName_style_fill',
  206. optionField: 'legendItemName.style.fill',
  207. value: '#595959',
  208. tabName: 'custom',
  209. groupName: 'legend'
  210. },
  211. // X轴 xAxis
  212. {
  213. label: '标题',
  214. type: 'input',
  215. field: 'xAxis_title_text',
  216. optionField: 'xAxis.title.text',
  217. value: '',
  218. tabName: 'custom',
  219. groupName: 'xAxis'
  220. },
  221. {
  222. label: '标题位置',
  223. type: 'select',
  224. field: 'xAxis_title_position',
  225. optionField: 'xAxis.title.position',
  226. value: 'end',
  227. tabName: 'custom',
  228. options: [
  229. {
  230. label: '左',
  231. value: 'start'
  232. },
  233. {
  234. label: '中',
  235. value: 'center'
  236. },
  237. {
  238. label: '右',
  239. value: 'end'
  240. }],
  241. groupName: 'xAxis'
  242. },
  243. {
  244. label: '标题字体大小',
  245. type: 'inputNumber',
  246. field: 'xAxis_title_style_fontSize',
  247. optionField: 'xAxis.title.style.fontSize',
  248. value: 12,
  249. tabName: 'custom',
  250. groupName: 'xAxis'
  251. },
  252. {
  253. label: '标题颜色',
  254. type: 'colorPicker',
  255. field: 'xAxis_title_style_fill',
  256. optionField: 'xAxis.title.style.fill',
  257. // 是否多选
  258. multiple: false,
  259. value: '#8C8C8C',
  260. tabName: 'custom',
  261. groupName: 'xAxis'
  262. },
  263. {
  264. label: '标签大小',
  265. type: 'inputNumber',
  266. field: 'xAxis_label_style_fontSize',
  267. optionField: 'xAxis.label.style.fontSize',
  268. value: 12,
  269. tabName: 'custom',
  270. groupName: 'xAxis'
  271. },
  272. {
  273. label: '标签颜色',
  274. type: 'colorPicker',
  275. field: 'xAxis_label_style_fill',
  276. optionField: 'xAxis.label.style.fill',
  277. // 是否多选
  278. multiple: false,
  279. value: '#8C8C8C',
  280. tabName: 'custom',
  281. groupName: 'xAxis'
  282. },
  283. {
  284. label: '轴线宽度',
  285. type: 'inputNumber',
  286. field: 'xAxis_line_style_lineWidth',
  287. optionField: 'xAxis.line.style.lineWidth',
  288. value: 1,
  289. tabName: 'custom',
  290. groupName: 'xAxis'
  291. },
  292. {
  293. label: '轴线颜色',
  294. type: 'colorPicker',
  295. field: 'xAxis_line_style_stroke',
  296. optionField: 'xAxis.line.style.stroke',
  297. // 是否多选
  298. multiple: false,
  299. value: '#d0d0d0',
  300. tabName: 'custom',
  301. groupName: 'xAxis'
  302. },
  303. {
  304. label: '刻度线宽度',
  305. type: 'inputNumber',
  306. field: 'xAxis_tickLine_style_lineWidth',
  307. optionField: 'xAxis.tickLine.style.lineWidth',
  308. value: 1,
  309. tabName: 'custom',
  310. groupName: 'xAxis'
  311. },
  312. {
  313. label: '刻度线颜色',
  314. type: 'colorPicker',
  315. field: 'xAxis_tickLine_style_stroke',
  316. optionField: 'xAxis.tickLine.style.stroke',
  317. // 是否多选
  318. multiple: false,
  319. value: '#d0d0d0',
  320. tabName: 'custom',
  321. groupName: 'xAxis'
  322. },
  323. {
  324. label: '标签过多时旋转',
  325. type: 'switch',
  326. field: 'xAxis_label_autoRotate',
  327. optionField: 'xAxis.label.autoRotate',
  328. value: true,
  329. tabName: 'custom',
  330. groupName: 'xAxis'
  331. },
  332. {
  333. label: '标签过多时隐藏',
  334. type: 'switch',
  335. field: 'xAxis_label_autoHide',
  336. optionField: 'xAxis.label.autoHide',
  337. value: false,
  338. tabName: 'custom',
  339. groupName: 'xAxis'
  340. },
  341. {
  342. label: '标签过长时省略',
  343. type: 'switch',
  344. field: 'xAxis_label_autoEllipsis',
  345. optionField: 'xAxis.label.autoEllipsis',
  346. value: false,
  347. tabName: 'custom',
  348. groupName: 'xAxis'
  349. },
  350. // Y轴 yAxis
  351. {
  352. label: '标题',
  353. type: 'input',
  354. field: 'yAxis_title_text',
  355. optionField: 'yAxis.title.text',
  356. value: '',
  357. tabName: 'custom',
  358. groupName: 'yAxis'
  359. },
  360. {
  361. label: '标题位置',
  362. type: 'select',
  363. field: 'yAxis_title_position',
  364. optionField: 'yAxis.title.position',
  365. value: 'end',
  366. tabName: 'custom',
  367. options: [
  368. {
  369. label: '上',
  370. value: 'end'
  371. },
  372. {
  373. label: '中',
  374. value: 'center'
  375. },
  376. {
  377. label: '下',
  378. value: 'start'
  379. }],
  380. groupName: 'yAxis'
  381. },
  382. {
  383. label: '标题字体大小',
  384. type: 'inputNumber',
  385. field: 'yAxis_title_style_fontSize',
  386. optionField: 'yAxis.title.style.fontSize',
  387. value: 12,
  388. tabName: 'custom',
  389. groupName: 'yAxis'
  390. },
  391. {
  392. label: '标题颜色',
  393. type: 'colorPicker',
  394. field: 'yAxis_title_style_fill',
  395. optionField: 'yAxis.title.style.fill',
  396. // 是否多选
  397. multiple: false,
  398. value: '#8C8C8C',
  399. tabName: 'custom',
  400. groupName: 'yAxis'
  401. },
  402. {
  403. label: '显示标签',
  404. type: 'switchNumber',
  405. field: 'yAxis_label_style_opacity',
  406. optionField: 'yAxis.label.style.opacity',
  407. value: 1,
  408. tabName: 'custom',
  409. groupName: 'yAxis'
  410. },
  411. {
  412. label: '标签字体大小',
  413. type: 'inputNumber',
  414. field: 'yAxis_label_style_fontSize',
  415. optionField: 'yAxis.label.style.fontSize',
  416. value: 12,
  417. tabName: 'custom',
  418. groupName: 'yAxis'
  419. },
  420. {
  421. label: '标签字体颜色',
  422. type: 'colorPicker',
  423. field: 'yAxis_label_style_fill',
  424. optionField: 'yAxis.label.style.fill',
  425. // 是否多选
  426. multiple: false,
  427. value: '#8C8C8C',
  428. tabName: 'custom',
  429. groupName: 'yAxis'
  430. },
  431. {
  432. label: '轴线宽度',
  433. type: 'inputNumber',
  434. field: 'yAxis_line_lineWidth',
  435. optionField: 'yAxis.line.style.lineWidth',
  436. value: 0,
  437. tabName: 'custom',
  438. groupName: 'yAxis'
  439. },
  440. {
  441. label: '轴线颜色',
  442. type: 'colorPicker',
  443. field: 'yAxis_line_stroke',
  444. optionField: 'yAxis.line.style.stroke',
  445. // 是否多选
  446. multiple: false,
  447. value: '#d0d0d0',
  448. tabName: 'custom',
  449. groupName: 'yAxis'
  450. },
  451. // 边距 padding
  452. {
  453. label: '图表边距',
  454. type: 'padding',
  455. field: 'appendPadding',
  456. optionField: 'appendPadding',
  457. value: [16, 16, 16, 16],
  458. tabName: 'custom',
  459. groupName: 'padding'
  460. }
  461. ]
  462. // 模拟数据
  463. const data = [
  464. { name: 'China', year: '2000', gdp: 1211346869605.24 },
  465. { name: 'China', year: '2001', gdp: 1339395718865.3 },
  466. { name: 'China', year: '2002', gdp: 1470550015081.55 },
  467. { name: 'China', year: '2003', gdp: 1660287965662.68 },
  468. { name: 'China', year: '2004', gdp: 1955347004963.27 },
  469. { name: 'China', year: '2005', gdp: 2285965892360.54 },
  470. { name: 'China', year: '2006', gdp: 2752131773355.16 },
  471. { name: 'China', year: '2007', gdp: 3550342425238.25 },
  472. { name: 'China', year: '2008', gdp: 4594306848763.08 },
  473. { name: 'China', year: '2009', gdp: 5101702432883.45 },
  474. { name: 'China', year: '2010', gdp: 6087164527421.24 },
  475. { name: 'China', year: '2011', gdp: 7551500425597.77 },
  476. { name: 'China', year: '2012', gdp: 8532230724141.76 },
  477. { name: 'China', year: '2013', gdp: 9570405758739.79 },
  478. { name: 'China', year: '2014', gdp: 10438529153237.6 },
  479. { name: 'China', year: '2015', gdp: 11015542352468.9 },
  480. { name: 'China', year: '2016', gdp: 11137945669350.6 },
  481. { name: 'China', year: '2017', gdp: 12143491448186.1 },
  482. { name: 'China', year: '2018', gdp: 13608151864637.9 },
  483. { name: 'United States', year: '2000', gdp: 10252345464000 },
  484. { name: 'United States', year: '2001', gdp: 10581821399000 },
  485. { name: 'United States', year: '2002', gdp: 10936419054000 },
  486. { name: 'United States', year: '2003', gdp: 11458243878000 },
  487. { name: 'United States', year: '2004', gdp: 12213729147000 },
  488. { name: 'United States', year: '2005', gdp: 13036640229000 },
  489. { name: 'United States', year: '2006', gdp: 13814611414000 },
  490. { name: 'United States', year: '2007', gdp: 14451858650000 },
  491. { name: 'United States', year: '2008', gdp: 14712844084000 },
  492. { name: 'United States', year: '2009', gdp: 14448933025000 },
  493. { name: 'United States', year: '2010', gdp: 14992052727000 },
  494. { name: 'United States', year: '2011', gdp: 15542581104000 },
  495. { name: 'United States', year: '2012', gdp: 16197007349000 },
  496. { name: 'United States', year: '2013', gdp: 16784849190000 },
  497. { name: 'United States', year: '2014', gdp: 17521746534000 },
  498. { name: 'United States', year: '2015', gdp: 18219297584000 },
  499. { name: 'United States', year: '2016', gdp: 18707188235000 },
  500. { name: 'United States', year: '2017', gdp: 19485393853000 },
  501. { name: 'United States', year: '2018', gdp: 20544343456936.5 },
  502. { name: 'United Kingdom', year: '2000', gdp: 1657816613708.58 },
  503. { name: 'United Kingdom', year: '2001', gdp: 1640246149417.01 },
  504. { name: 'United Kingdom', year: '2002', gdp: 1784473920863.31 },
  505. { name: 'United Kingdom', year: '2003', gdp: 2053018775510.2 },
  506. { name: 'United Kingdom', year: '2004', gdp: 2416931526913.22 },
  507. { name: 'United Kingdom', year: '2005', gdp: 2538680000000 },
  508. { name: 'United Kingdom', year: '2006', gdp: 2713749770009.2 },
  509. { name: 'United Kingdom', year: '2007', gdp: 3100882352941.18 },
  510. { name: 'United Kingdom', year: '2008', gdp: 2922667279411.76 },
  511. { name: 'United Kingdom', year: '2009', gdp: 2410909799034.12 },
  512. { name: 'United Kingdom', year: '2010', gdp: 2475244321361.11 },
  513. { name: 'United Kingdom', year: '2011', gdp: 2659310054646.23 },
  514. { name: 'United Kingdom', year: '2012', gdp: 2704887678386.72 },
  515. { name: 'United Kingdom', year: '2013', gdp: 2786022872706.81 },
  516. { name: 'United Kingdom', year: '2014', gdp: 3063803240208.01 },
  517. { name: 'United Kingdom', year: '2015', gdp: 2928591002002.51 },
  518. { name: 'United Kingdom', year: '2016', gdp: 2694283209613.29 },
  519. { name: 'United Kingdom', year: '2017', gdp: 2666229179958.01 },
  520. { name: 'United Kingdom', year: '2018', gdp: 2855296731521.96 },
  521. { name: 'Russian', year: '2000', gdp: 259710142196.94 },
  522. { name: 'Russian', year: '2001', gdp: 306602070620.5 },
  523. { name: 'Russian', year: '2002', gdp: 345470494417.86 },
  524. { name: 'Russian', year: '2003', gdp: 430347770731.79 },
  525. { name: 'Russian', year: '2004', gdp: 591016690742.8 },
  526. { name: 'Russian', year: '2005', gdp: 764017107992.39 },
  527. { name: 'Russian', year: '2006', gdp: 989930542278.7 },
  528. { name: 'Russian', year: '2007', gdp: 1299705764823.62 },
  529. { name: 'Russian', year: '2008', gdp: 1660846387624.78 },
  530. { name: 'Russian', year: '2009', gdp: 1222644282201.86 },
  531. { name: 'Russian', year: '2010', gdp: 1524917468442.01 },
  532. { name: 'Russian', year: '2011', gdp: 2051661732059.78 },
  533. { name: 'Russian', year: '2012', gdp: 2210256976945.38 },
  534. { name: 'Russian', year: '2013', gdp: 2297128039058.21 },
  535. { name: 'Russian', year: '2014', gdp: 2059984158438.46 },
  536. { name: 'Russian', year: '2015', gdp: 1363594369577.82 },
  537. { name: 'Russian', year: '2016', gdp: 1282723881134.01 },
  538. { name: 'Russian', year: '2017', gdp: 1578624060588.26 },
  539. { name: 'Russian', year: '2018', gdp: 1657554647149.87 },
  540. { name: 'Japan', year: '2000', gdp: 4887519660744.86 },
  541. { name: 'Japan', year: '2001', gdp: 4303544259842.72 },
  542. { name: 'Japan', year: '2002', gdp: 4115116279069.77 },
  543. { name: 'Japan', year: '2003', gdp: 4445658071221.86 },
  544. { name: 'Japan', year: '2004', gdp: 4815148854362.11 },
  545. { name: 'Japan', year: '2005', gdp: 4755410630912.14 },
  546. { name: 'Japan', year: '2006', gdp: 4530377224970.4 },
  547. { name: 'Japan', year: '2007', gdp: 4515264514430.57 },
  548. { name: 'Japan', year: '2008', gdp: 5037908465114.48 },
  549. { name: 'Japan', year: '2009', gdp: 5231382674593.7 },
  550. { name: 'Japan', year: '2010', gdp: 5700098114744.41 },
  551. { name: 'Japan', year: '2011', gdp: 6157459594823.72 },
  552. { name: 'Japan', year: '2012', gdp: 6203213121334.12 },
  553. { name: 'Japan', year: '2013', gdp: 5155717056270.83 },
  554. { name: 'Japan', year: '2014', gdp: 4850413536037.84 },
  555. { name: 'Japan', year: '2015', gdp: 4389475622588.97 },
  556. { name: 'Japan', year: '2016', gdp: 4926667087367.51 },
  557. { name: 'Japan', year: '2017', gdp: 4859950558538.97 },
  558. { name: 'Japan', year: '2018', gdp: 4971323079771.87 }
  559. ]
  560. // 配置处理脚本
  561. const optionHandler = 'option.legend = option.legendEnable ? {position: setting.find(settingItem=>settingItem.field === \'legendPosition\').value} : false;' +
  562. '\n if (option.legendEnable) {\n' +
  563. ' option.legend.itemName = option.legendItemName\n' +
  564. ' };' +
  565. 'option.yAxis.grid.line.style.lineDash = [4,setting.find(settingItem=>settingItem.field === \'yAxis_grid_line_style_lineDash\').value]'
  566. // 数据处理脚本
  567. const dataHandler = ''
  568. // 图表配置 new Line('domName', option)
  569. const option = {
  570. // 数据将要放入到哪个字段中
  571. dataKey: 'data',
  572. data,
  573. color: ['#5B8FF9', '#61DDAA', '#5D7092', '#F6BD16', '#6F5EF9', '#6DC8EC', '#945FB9', '#FF9845', '#1E9493', '#FF99C3'],
  574. xField: 'year',
  575. yField: 'gdp',
  576. seriesField: 'name',
  577. appendPadding: [16, 16, 16, 16], // 设置图标的边距
  578. xAxis: {
  579. title: {
  580. text: '',
  581. position: 'end',
  582. style: {
  583. fill: '#8C8C8C',
  584. fontSize: 12
  585. }
  586. },
  587. label: {
  588. autoRotate: true,
  589. autoHide: false,
  590. autoEllipsis: true,
  591. style: {
  592. fill: '#8C8C8C',
  593. fontSize: 12
  594. }
  595. },
  596. line: {
  597. style: {
  598. stroke: '#d0d0d0',
  599. lineWidth: 1
  600. }
  601. },
  602. tickLine: {
  603. style: {
  604. stroke: '#d0d0d0',
  605. lineWidth: 1
  606. }
  607. }
  608. },
  609. yAxis: {
  610. title: {
  611. text: '',
  612. position: 'end',
  613. autoRotate: false,
  614. // rotation: Math.PI / 2,
  615. style: {
  616. fill: '#8C8C8C',
  617. fontSize: 12
  618. }
  619. },
  620. grid: {
  621. line: {
  622. style: {
  623. stroke: '#d0d0d0',
  624. lineWidth: 1,
  625. lineDash: [4, 5],
  626. strokeOpacity: 0.7
  627. }
  628. }
  629. },
  630. label: {
  631. formatter: (v) => {
  632. if (v < 1e3) return v
  633. if (v >= 1e3 && v < 1e6) return `${(v / 1e3).toFixed(1)} K`
  634. if (v >= 1e6 && v < 1e9) return `${(v / 1e6).toFixed(1)} M`
  635. if (v >= 1e9 && v < 1e12) return `${(v / 1e9).toFixed(1)} B`
  636. return `${(v / 10e8).toFixed(1)} B`
  637. },
  638. style: {
  639. fill: '#8C8C8C',
  640. fontSize: 12,
  641. opacity: 1
  642. }
  643. },
  644. line: {
  645. style: {
  646. stroke: '#d0d0d0',
  647. lineWidth: 0
  648. }
  649. }
  650. },
  651. legendEnable: false,
  652. legendLayout: 'vertical',
  653. legendPosition: 'top',
  654. legend: false,
  655. legendItemName: {
  656. style: {
  657. fill: '#595959',
  658. fontSize: 12,
  659. fontWeight: 400
  660. }
  661. },
  662. smooth: true,
  663. // @TODO 后续会换一种动画方式
  664. animation: {
  665. appear: {
  666. animation: 'path-in',
  667. duration: 5000
  668. }
  669. },
  670. lineStyle: {
  671. lineWidth: 2
  672. }
  673. }
  674. export default {
  675. category,
  676. version,
  677. title,
  678. chartType,
  679. name,
  680. option,
  681. setting,
  682. optionHandler,
  683. dataHandler
  684. }