chartFormItemsMap.ts 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874
  1. import { IFormItem } from "../../cusForm";
  2. /**
  3. * 用于快速配置图表配置项
  4. *
  5. * prop: option的路径
  6. * format:转换数据
  7. *
  8. * */
  9. export const chartFormItemsMap: Record<string, IFormItem> = {
  10. /* 标题 */
  11. title: {
  12. label: "标题",
  13. prop: "title",
  14. type: "group",
  15. children: [
  16. {
  17. label: " ",
  18. prop: "title.show",
  19. type: "checkboxGroup",
  20. fieldProps: {
  21. options: [{ label: "标题可见", value: true }],
  22. },
  23. defaultValue: [],
  24. format: (formatModel, value) => {
  25. formatModel.value['title.show'] = value.length ? [true] : [];
  26. }
  27. },
  28. {
  29. type: "dependency",
  30. label: "",
  31. prop: "",
  32. name: ["title.show"],
  33. children: (model) => {
  34. return model['title.show'].length
  35. ? [
  36. {
  37. label: "文本",
  38. prop: "title.text",
  39. type: "input",
  40. defaultValue: "图表标题",
  41. },
  42. {
  43. label: "位置",
  44. prop: "title.left",
  45. type: "position",
  46. defaultValue: "center",
  47. },
  48. {
  49. label: "样式",
  50. prop: "title.textStyle",
  51. type: "fontStyle",
  52. defaultValue: {
  53. size: 18,
  54. bold: true,
  55. italic: false,
  56. },
  57. format: (formatModel, value) => {
  58. formatModel.value['title.textStyle'] = {
  59. color: value.color,
  60. fontSize: value.size,
  61. fontWeight: value.bold ? "bold" : "normal",
  62. fontStyle: value.italic ? "italic" : "normal",
  63. };
  64. }
  65. },
  66. {
  67. label: "背景",
  68. prop: "",
  69. type: "divider",
  70. },
  71. {
  72. label: "填充",
  73. prop: "title.backgroundColor",
  74. type: "backgroundSelect",
  75. fieldProps: {
  76. filterOptions: ["image"],
  77. },
  78. defaultValue: {
  79. type: "color",
  80. color: "#fff",
  81. },
  82. format: (formatModel, value) => {
  83. formatModel.value['title.backgroundColor'] = value.color;
  84. }
  85. },
  86. {
  87. label: "圆角",
  88. prop: "title.borderRadius",
  89. type: "inputNumber",
  90. fieldProps: {
  91. addonAfter: "px",
  92. },
  93. defaultValue: 0,
  94. },
  95. ]
  96. : [];
  97. },
  98. },
  99. ],
  100. },
  101. /* 图例 */
  102. legend: {
  103. label: "图例",
  104. prop: "legend",
  105. type: "group",
  106. children: [
  107. {
  108. label: " ",
  109. prop: "legend.show",
  110. type: "checkboxGroup",
  111. fieldProps: {
  112. options: [{ label: "图例可见", value: true }],
  113. },
  114. defaultValue: [true],
  115. format: (formatModel, value) => {
  116. formatModel.value['legend.show'] = value.length ? [true] : [];
  117. }
  118. },
  119. {
  120. type: "dependency",
  121. label: "",
  122. prop: "",
  123. name: ["legend.show"],
  124. children: (model) => {
  125. return model['legend.show'].length
  126. ? [
  127. {
  128. label: "位置",
  129. prop: "legend.position",
  130. type: "position",
  131. fieldProps: {
  132. type: "round",
  133. },
  134. defaultValue: "top",
  135. },
  136. {
  137. label: "样式",
  138. prop: "legend.textStyle",
  139. type: "fontStyle",
  140. defaultValue: {
  141. size: 12,
  142. bold: false,
  143. italic: false,
  144. },
  145. format: (formatModel, value) => {
  146. formatModel.value['legend.textStyle'] = {
  147. color: value.color,
  148. fontSize: value.size,
  149. fontWeight: value.bold ? "bold" : "normal",
  150. fontStyle: value.italic ? "italic" : "normal",
  151. };
  152. }
  153. },
  154. {
  155. label: "边框",
  156. prop: "",
  157. type: "divider",
  158. },
  159. {
  160. label: "线宽",
  161. prop: "legend.borderWidth",
  162. type: "inputNumber",
  163. fieldProps: {
  164. addonAfter: "px",
  165. },
  166. defaultValue: 0,
  167. },
  168. {
  169. label: "颜色",
  170. prop: "legend.borderColor",
  171. type: "colorSelect",
  172. defaultValue: "#ccc",
  173. },
  174. {
  175. label: "圆角",
  176. prop: "legend.borderRadius",
  177. type: "inputNumber",
  178. fieldProps: {
  179. addonAfter: "px",
  180. },
  181. defaultValue: 0,
  182. },
  183. {
  184. label: "背景",
  185. prop: "",
  186. type: "divider",
  187. },
  188. {
  189. label: "背景",
  190. prop: "legend.backgroundColor",
  191. type: "backgroundSelect",
  192. fieldProps: {
  193. filterOptions: ["image"],
  194. },
  195. defaultValue: {
  196. type: "color",
  197. color: "#fff",
  198. },
  199. format: (formatModel, value) => {
  200. formatModel.value['legend.backgroundColor'] = value.color;
  201. }
  202. },
  203. {
  204. label: "阴影",
  205. prop: "legend.shadowBlur",
  206. type: "radioGroup",
  207. fieldProps: {
  208. options: [
  209. { label: "开启", value: true },
  210. { label: "关闭", value: false },
  211. ],
  212. },
  213. defaultValue: false,
  214. format: (formatModel, value) => {
  215. formatModel.value['legend.shadowBlur'] = value ? 10 : 0;
  216. formatModel.value['legend.shadowColor'] = "#000";
  217. }
  218. },
  219. ]
  220. : [];
  221. },
  222. },
  223. ],
  224. },
  225. /* 系列 */
  226. series: {
  227. label: "系列",
  228. prop: "series.color",
  229. type: "group",
  230. children: [
  231. {
  232. label: "配色",
  233. prop: "colorScheme",
  234. type: "colorScheme",
  235. defaultValue: "",
  236. },
  237. ],
  238. },
  239. /* X轴 */
  240. xAxis: {
  241. label: "X 轴",
  242. prop: "xAxis",
  243. type: "group",
  244. children: [
  245. {
  246. label: "类型",
  247. prop: "xAxis.type",
  248. type: "select",
  249. fieldProps: {
  250. options: [
  251. { label: "类目坐标轴", value: "category" },
  252. { label: "数值坐标轴", value: "value" },
  253. { label: "时间坐标轴", value: "time" },
  254. ],
  255. },
  256. defaultValue: "category",
  257. },
  258. {
  259. label: " ",
  260. prop: "xAxis.showName",
  261. type: "checkboxGroup",
  262. fieldProps: {
  263. options: [
  264. { label: "显示轴标题", value: true },
  265. ],
  266. },
  267. defaultValue: [true],
  268. format: (formatModel, value) => {
  269. formatModel.value['xAxis.showName'] = value.length ? [true] : [];
  270. }
  271. },
  272. {
  273. label: "",
  274. prop: "",
  275. type: "dependency",
  276. name: ["xAxis.showName"],
  277. children: (model) => {
  278. return model['xAxis.showName'].length ? [
  279. {
  280. label: "标题内容",
  281. prop: "xAxis.name",
  282. type: "input",
  283. defaultValue: "X 轴标题",
  284. format: (formatModel, value) => {
  285. if(formatModel.value['xAxis.showName']) {
  286. formatModel.value['xAxis.name'] = value;
  287. formatModel.value['grid.bottom'] = 40;
  288. } else {
  289. formatModel.value['xAxis.name'] = "";
  290. formatModel.value['grid.bottom'] = 20;
  291. }
  292. }
  293. },
  294. {
  295. label: "标题位置",
  296. prop: "xAxis.nameLocation",
  297. type: "position",
  298. defaultValue: "center",
  299. format: (formatModel, value: 'left' | 'center' | 'right') => {
  300. const p = {
  301. left: "start",
  302. center: "middle",
  303. right: "end",
  304. }
  305. formatModel.value['xAxis.nameLocation'] = value ? p[value] : 'middle';
  306. }
  307. },
  308. {
  309. label: "标题样式",
  310. prop: "xAxis.nameTextStyle",
  311. type: "fontStyle",
  312. defaultValue: {
  313. size: 12,
  314. bold: false,
  315. italic: false
  316. },
  317. format: (formatModel, value) => {
  318. formatModel.value['xAxis.nameTextStyle'] = {
  319. color: value.color,
  320. fontSize: value.size,
  321. fontWeight: value.bold ? "bold" : "normal",
  322. fontStyle: value.italic ? "italic" : "normal",
  323. };
  324. }
  325. },
  326. ] : []
  327. }
  328. },
  329. {
  330. label: "轴线",
  331. prop: "",
  332. type: "divider",
  333. },
  334. {
  335. label: "线宽",
  336. prop: "xAxis.axisLine.width",
  337. type: "inputNumber",
  338. fieldProps: {
  339. addonAfter: "px",
  340. },
  341. defaultValue: 1,
  342. },
  343. {
  344. label: "颜色",
  345. prop: "xAxis.axisLine.color",
  346. type: "colorSelect",
  347. defaultValue: "#ccc",
  348. },
  349. {
  350. label: "刻度",
  351. prop: "",
  352. type: "divider",
  353. },
  354. {
  355. label: " ",
  356. prop: "xAxis.axisTick.show",
  357. type: "checkboxGroup",
  358. fieldProps: {
  359. options: [
  360. { label: "显示刻度", value: true },
  361. ],
  362. },
  363. defaultValue: [true],
  364. format: (formatModel, value) => {
  365. formatModel.value['xAxis.axisTick.show'] = value.length ? true : false;
  366. }
  367. },
  368. {
  369. label: "",
  370. prop: "",
  371. type: "dependency",
  372. name: ["xAxis.axisTick.show"],
  373. children: (model) => {
  374. return model['xAxis.axisTick.show'].length ? [
  375. {
  376. label: "刻度宽度",
  377. prop: "xAxis.axisTick.lineStyle.width",
  378. type: "inputNumber",
  379. fieldProps: {
  380. addonAfter: "px",
  381. },
  382. defaultValue: 5,
  383. },
  384. {
  385. label: "刻度颜色",
  386. prop: "xAxis.axisTick.lineStyle.color",
  387. type: "colorSelect",
  388. defaultValue: "#ccc",
  389. },
  390. ] : []
  391. }
  392. },
  393. {
  394. label: "标签",
  395. prop: "",
  396. type: "divider",
  397. },
  398. {
  399. label: "颜色",
  400. prop: "xAxis.axisLabel.color",
  401. type: "colorSelect",
  402. defaultValue: "#000",
  403. },
  404. {
  405. label: "样式",
  406. prop: "xAxis.axisLabel",
  407. type: "fontStyle",
  408. defaultValue: {
  409. size: 12,
  410. bold: false,
  411. italic: false
  412. },
  413. format: (formatModel, value) => {
  414. formatModel.value['xAxis.axisLabel.color'] = value.color;
  415. formatModel.value['xAxis.axisLabel.fontSize'] = value.size;
  416. formatModel.value['xAxis.axisLabel.fontWeight'] = value.bold ? "bold" : "normal";
  417. formatModel.value['xAxis.axisLabel.fontStyle'] = value.italic ? "italic" : "normal";
  418. }
  419. },
  420. ],
  421. },
  422. /* Y 轴 */
  423. yAxis: {
  424. label: "Y 轴",
  425. prop: "yAxis",
  426. type: "group",
  427. children: [
  428. {
  429. label: " ",
  430. prop: "yAliasShowTitle",
  431. type: "checkboxGroup",
  432. fieldProps: {
  433. options: [
  434. { label: "显示轴标题", value: true },
  435. ],
  436. },
  437. defaultValue: [],
  438. },
  439. {
  440. label: "",
  441. prop: "",
  442. type: "dependency",
  443. name: ["yAliasShowTitle"],
  444. children: ({ yAliasShowTitle }) => {
  445. return yAliasShowTitle.length
  446. ? [
  447. {
  448. label: "标题内容",
  449. prop: "yAliasTitle",
  450. type: "input",
  451. defaultValue: "Y 轴标题",
  452. },
  453. {
  454. label: "标题位置",
  455. prop: "yAliasPosition",
  456. type: "position",
  457. defaultValue: "center",
  458. },
  459. {
  460. label: "标题样式",
  461. prop: "yAliasStyle",
  462. type: "fontStyle",
  463. defaultValue: {
  464. size: 12,
  465. bold: false,
  466. italic: false,
  467. },
  468. },
  469. ]
  470. : [];
  471. },
  472. },
  473. {
  474. label: "轴线",
  475. prop: "",
  476. type: "divider",
  477. },
  478. {
  479. label: "线宽",
  480. prop: "yAliasLineWidth",
  481. type: "inputNumber",
  482. fieldProps: {
  483. addonAfter: "px",
  484. },
  485. defaultValue: 1,
  486. },
  487. {
  488. label: "颜色",
  489. prop: "yAliasLineColor",
  490. type: "colorSelect",
  491. defaultValue: "#ccc",
  492. },
  493. {
  494. label: "刻度",
  495. prop: "",
  496. type: "divider",
  497. },
  498. {
  499. label: " ",
  500. prop: "yAliasTickShow",
  501. type: "checkboxGroup",
  502. fieldProps: {
  503. options: [
  504. { label: "显示刻度", value: true },
  505. ],
  506. },
  507. defaultValue: [true],
  508. },
  509. {
  510. label: "",
  511. prop: "",
  512. type: "dependency",
  513. name: ['yAliasTickShow'],
  514. children: ({ yAliasTickShow }) => {
  515. return yAliasTickShow.length ? [
  516. {
  517. label: "刻度长度",
  518. prop: "yAliasTickLength",
  519. type: "inputNumber",
  520. fieldProps: {
  521. addonAfter: "px",
  522. },
  523. defaultValue: 5,
  524. },
  525. {
  526. label: "刻度颜色",
  527. prop: "yAliasTickColor",
  528. type: "colorSelect",
  529. defaultValue: "#ccc",
  530. },
  531. ] : []
  532. }
  533. },
  534. {
  535. label: "标签",
  536. prop: "",
  537. type: "divider",
  538. },
  539. {
  540. label: "颜色",
  541. prop: "yAliasLabelColor",
  542. type: "colorSelect",
  543. defaultValue: "#000",
  544. },
  545. {
  546. label: "样式",
  547. prop: "yAliasLabelStyle",
  548. type: "fontStyle",
  549. defaultValue: {
  550. size: 12,
  551. bold: false,
  552. italic: false
  553. },
  554. },
  555. ],
  556. },
  557. /* 提示 */
  558. tooltip: {
  559. label: "提示",
  560. prop: "tooltip",
  561. type: "group",
  562. children: [
  563. {
  564. label: " ",
  565. prop: "showTooltip",
  566. type: "checkboxGroup",
  567. fieldProps: {
  568. options: [{ label: "提示可见", value: true }],
  569. },
  570. defaultValue: [true],
  571. },
  572. {
  573. label: "",
  574. prop: "",
  575. type: "dependency",
  576. name: ["showTooltip"],
  577. children: ({ showTooltip }) => {
  578. return showTooltip.length
  579. ? [
  580. {
  581. label: "文本",
  582. prop: "tooltipValueType",
  583. type: "checkboxGroup",
  584. fieldProps: {
  585. options: [
  586. { label: "分类名", value: "category" },
  587. { label: "系列名", value: "serie" },
  588. { label: "数值", value: "value" },
  589. { label: "百分比", value: "percent" },
  590. ],
  591. },
  592. defaultValue: ["value"],
  593. },
  594. {
  595. label: "格式化",
  596. prop: "tooltipFormatter",
  597. type: "input",
  598. tip: "支持字符串模板和回调函数",
  599. defaultValue: "{value}",
  600. },
  601. {
  602. label: "样式",
  603. prop: "tooltipStyle",
  604. type: "fontStyle",
  605. defaultValue: {
  606. size: 12,
  607. bold: false,
  608. italic: false,
  609. },
  610. },
  611. {
  612. label: "边框",
  613. prop: "",
  614. type: "divider",
  615. },
  616. {
  617. label: "线宽",
  618. prop: "tooltipBorderWidth",
  619. type: "inputNumber",
  620. fieldProps: {
  621. addonAfter: "px",
  622. },
  623. defaultValue: 1,
  624. },
  625. {
  626. label: "颜色",
  627. prop: "tooltipBorderColor",
  628. type: "colorSelect",
  629. defaultValue: "#ccc",
  630. },
  631. {
  632. label: "圆角",
  633. prop: "tooltipBorderRadius",
  634. type: "inputNumber",
  635. fieldProps: {
  636. addonAfter: "px",
  637. },
  638. defaultValue: 0,
  639. },
  640. {
  641. label: "背景",
  642. prop: "",
  643. type: "divider",
  644. },
  645. {
  646. label: "填充",
  647. prop: "tooltipBackground",
  648. type: "backgroundSelect",
  649. fieldProps: {
  650. filterOptions: ["image"],
  651. },
  652. defaultValue: {
  653. type: "color",
  654. color: "#fff",
  655. },
  656. },
  657. {
  658. label: "背景透明度",
  659. prop: "tooltipBackgroudOpacity",
  660. type: "slider",
  661. defaultValue: 100,
  662. },
  663. {
  664. label: "阴影",
  665. prop: "tooltipShadow",
  666. type: "radioGroup",
  667. fieldProps: {
  668. options: [
  669. { label: "开启", value: true },
  670. { label: "关闭", value: false },
  671. ],
  672. },
  673. defaultValue: false,
  674. },
  675. ]
  676. : [];
  677. },
  678. },
  679. ],
  680. },
  681. /* 背景 */
  682. background: {
  683. label: "背景",
  684. prop: "background",
  685. type: "group",
  686. children: [
  687. {
  688. label: "边框",
  689. prop: "",
  690. type: "divider",
  691. },
  692. {
  693. label: "线宽",
  694. prop: "backgroundBorderWidth",
  695. type: "inputNumber",
  696. fieldProps: {
  697. addonAfter: "px",
  698. },
  699. defaultValue: 0,
  700. },
  701. {
  702. label: "颜色",
  703. prop: "backgroundBorderColor",
  704. type: "colorSelect",
  705. defaultValue: "#ccc",
  706. },
  707. {
  708. label: "圆角",
  709. prop: "backgroundBorderRadius",
  710. type: "inputNumber",
  711. fieldProps: {
  712. addonAfter: "px",
  713. },
  714. defaultValue: 0,
  715. },
  716. {
  717. label: "背景",
  718. prop: "",
  719. type: "divider",
  720. },
  721. {
  722. label: "填充",
  723. prop: "backgroundBackground",
  724. type: "backgroundSelect",
  725. fieldProps: {
  726. filterOptions: ["image"],
  727. },
  728. defaultValue: {
  729. type: "color",
  730. color: "#fff",
  731. },
  732. },
  733. {
  734. label: "背景透明度",
  735. prop: "backgroundBackgroudOpacity",
  736. type: "slider",
  737. defaultValue: 100,
  738. },
  739. {
  740. label: "阴影",
  741. prop: "backgroundShadow",
  742. type: "radioGroup",
  743. fieldProps: {
  744. options: [
  745. { label: "开启", value: true },
  746. { label: "关闭", value: false },
  747. ],
  748. },
  749. defaultValue: false,
  750. },
  751. ],
  752. },
  753. };
  754. /* 标签配置在每个系列下,获取标签配置 */
  755. export const getLabelFormItems = () => {
  756. return {
  757. label: "标签",
  758. prop: "label",
  759. type: "group",
  760. children: [
  761. {
  762. label: " ",
  763. prop: "showLabel",
  764. type: "checkboxGroup",
  765. fieldProps: {
  766. options: [{ label: "标签可见", value: true }],
  767. },
  768. defaultValue: [],
  769. },
  770. {
  771. label: "",
  772. prop: "",
  773. type: "dependency",
  774. name: ["showLabel"],
  775. children: ({ showLabel }) => {
  776. return showLabel.length
  777. ? [
  778. {
  779. label: "文本",
  780. prop: "labelValueType",
  781. type: "checkboxGroup",
  782. fieldProps: {
  783. options: [
  784. { label: "分类名", value: "name" },
  785. { label: "系列名", value: "seriesType" },
  786. { label: "数值", value: "value" },
  787. // { label: "百分比", value: "percent" },
  788. ],
  789. },
  790. defaultValue: ["value"],
  791. },
  792. {
  793. label: "颜色",
  794. prop: "labelColor",
  795. type: "colorSelect",
  796. defaultValue: "#000",
  797. },
  798. {
  799. label: "样式",
  800. prop: "labelStyle",
  801. type: "fontStyle",
  802. defaultValue: {
  803. size: 12,
  804. bold: false,
  805. italic: false,
  806. },
  807. },
  808. {
  809. label: "布局",
  810. prop: "",
  811. type: "divider",
  812. },
  813. {
  814. label: "位置",
  815. prop: "labelPosition",
  816. type: "radioGroup",
  817. fieldProps: {
  818. options: [
  819. { label: "内部", value: "insideTop" },
  820. { label: "外部", value: "top" },
  821. { label: "中间", value: "inside" },
  822. ],
  823. },
  824. defaultValue: "insideTop",
  825. },
  826. {
  827. label: "文本方向",
  828. prop: "labelDirection",
  829. type: "radioGroup",
  830. fieldProps: {
  831. options: [
  832. { label: "水平", value: "horizontal" },
  833. { label: "垂直", value: "vertical" },
  834. ],
  835. },
  836. defaultValue: "horizontal",
  837. },
  838. {
  839. label: "边框",
  840. prop: "",
  841. type: "divider",
  842. },
  843. {
  844. label: "线宽",
  845. prop: "labelBorderWidth",
  846. type: "inputNumber",
  847. fieldProps: {
  848. addonAfter: "px",
  849. },
  850. defaultValue: 0,
  851. },
  852. {
  853. label: "颜色",
  854. prop: "labelBorderColor",
  855. type: "colorSelect",
  856. defaultValue: "#ccc",
  857. },
  858. {
  859. label: "圆角",
  860. prop: "labelBorderRadius",
  861. type: "inputNumber",
  862. fieldProps: {
  863. addonAfter: "px",
  864. },
  865. defaultValue: 0,
  866. },
  867. ]
  868. : [];
  869. },
  870. },
  871. ],
  872. }
  873. }