chartFormItemsMap.ts 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081
  1. import { IFormItem } from "../../cusForm";
  2. import { colorPreset } from "./index";
  3. import { get } from "lodash-es";
  4. /**
  5. * 用于快速配置图表配置项
  6. *
  7. * prop: 图表option的路径
  8. * format:转换数据
  9. *
  10. * */
  11. export const chartFormItemsMap: Record<string, IFormItem> = {
  12. /* 标题 */
  13. title: {
  14. label: "标题",
  15. prop: "title",
  16. type: "group",
  17. children: [
  18. {
  19. label: " ",
  20. prop: "title.show",
  21. type: "checkboxGroup",
  22. fieldProps: {
  23. options: [{ label: "标题可见", value: true }],
  24. },
  25. defaultValue: [],
  26. format: (formatModel, value) => {
  27. formatModel.value["title.show"] = value?.length ? true : false;
  28. },
  29. valueToForm: (value) => {
  30. return value ? [true] : [];
  31. }
  32. },
  33. {
  34. type: "dependency",
  35. label: "",
  36. prop: "",
  37. name: ["title.show"],
  38. children: (model) => {
  39. return model["title.show"].length
  40. ? [
  41. {
  42. label: "文本",
  43. prop: "title.text",
  44. type: "input",
  45. defaultValue: "图表标题",
  46. },
  47. {
  48. label: "位置",
  49. prop: "title.left",
  50. type: "position",
  51. defaultValue: "center",
  52. },
  53. {
  54. label: "样式",
  55. prop: "title.textStyle",
  56. type: "fontStyle",
  57. defaultValue: {
  58. color: "#ffffffff",
  59. size: 18,
  60. bold: true,
  61. italic: false,
  62. },
  63. format: (formatModel, value) => {
  64. formatModel.value["title.textStyle"] = {
  65. color: value.color,
  66. fontSize: value.size,
  67. fontWeight: value.bold ? "bold" : "normal",
  68. fontStyle: value.italic ? "italic" : "normal",
  69. };
  70. },
  71. valueToForm: (_, model) => {
  72. return {
  73. color: get(model, 'title.textStyle.color', '#FFFFFF'),
  74. size: get(model, 'title.textStyle.size', 16),
  75. bold: get(model, 'title.textStyle.fontWeight') === 'bold',
  76. italic: get(model, 'title.textStyle.fontStyle') === 'italic',
  77. }
  78. }
  79. },
  80. {
  81. label: "背景",
  82. prop: "",
  83. type: "divider",
  84. },
  85. {
  86. label: "填充",
  87. prop: "title.backgroundColor",
  88. type: "backgroundSelect",
  89. fieldProps: {
  90. filterOptions: ["image"],
  91. },
  92. defaultValue: {
  93. type: "color",
  94. color: "#FFFFFF00",
  95. },
  96. format: (formatModel, value) => {
  97. formatModel.value["title.backgroundColor"] = value?.type === 'color' ? value.color : 'none';
  98. },
  99. valueToForm: (value) => {
  100. return !value || value === 'none'
  101. ? {
  102. type: 'none',
  103. color: '#000000ff'
  104. }
  105. : {
  106. type: "color",
  107. color: value.color,
  108. };
  109. },
  110. },
  111. {
  112. label: "圆角",
  113. prop: "title.borderRadius",
  114. type: "inputNumber",
  115. fieldProps: {
  116. addonAfter: "px",
  117. },
  118. defaultValue: 0,
  119. },
  120. ]
  121. : [];
  122. },
  123. },
  124. ],
  125. },
  126. /* 图例 */
  127. legend: {
  128. label: "图例",
  129. prop: "legend",
  130. type: "group",
  131. children: [
  132. {
  133. label: " ",
  134. prop: "legend.show",
  135. type: "checkboxGroup",
  136. fieldProps: {
  137. options: [{ label: "图例可见", value: true }],
  138. },
  139. defaultValue: [true],
  140. format: (formatModel, value) => {
  141. formatModel.value["legend.show"] = value?.length ? true : false;
  142. },
  143. valueToForm: (value) => {
  144. return value ? [true] : [];
  145. },
  146. },
  147. {
  148. type: "dependency",
  149. label: "",
  150. prop: "",
  151. name: ["legend.show"],
  152. children: (model) => {
  153. return model["legend.show"].length
  154. ? [
  155. {
  156. label: "位置",
  157. prop: "legend.position",
  158. type: "position",
  159. fieldProps: {
  160. type: "round",
  161. },
  162. defaultValue: "top",
  163. },
  164. {
  165. label: "样式",
  166. prop: "legend.textStyle",
  167. type: "fontStyle",
  168. defaultValue: {
  169. color: "#000000ff",
  170. size: 12,
  171. bold: false,
  172. italic: false,
  173. },
  174. format: (formatModel, value) => {
  175. formatModel.value["legend.textStyle"] = {
  176. color: value.color,
  177. fontSize: value.size,
  178. fontWeight: value.bold ? "bold" : "normal",
  179. fontStyle: value.italic ? "italic" : "normal",
  180. };
  181. },
  182. valueToForm: (_, model) => {
  183. return {
  184. color: get(model, 'legend.textStyle.color', '#000000ff'),
  185. size: get(model, 'legend.textStyle.fontSize', 12),
  186. bold: get(model, 'legend.textStyle.fontWeight') === 'bold',
  187. italic: get(model, 'legend.textStyle.fontStyle') === 'italic',
  188. }
  189. }
  190. },
  191. {
  192. label: "边框",
  193. prop: "",
  194. type: "divider",
  195. },
  196. {
  197. label: "线宽",
  198. prop: "legend.borderWidth",
  199. type: "inputNumber",
  200. fieldProps: {
  201. addonAfter: "px",
  202. },
  203. defaultValue: 0,
  204. },
  205. {
  206. label: "颜色",
  207. prop: "legend.borderColor",
  208. type: "colorSelect",
  209. defaultValue: "#ccc",
  210. },
  211. {
  212. label: "圆角",
  213. prop: "legend.borderRadius",
  214. type: "inputNumber",
  215. fieldProps: {
  216. addonAfter: "px",
  217. },
  218. defaultValue: 0,
  219. },
  220. {
  221. label: "背景",
  222. prop: "",
  223. type: "divider",
  224. },
  225. {
  226. label: "背景",
  227. prop: "legend.backgroundColor",
  228. type: "backgroundSelect",
  229. fieldProps: {
  230. filterOptions: ["image"],
  231. },
  232. defaultValue: {
  233. type: "color",
  234. color: "#fff",
  235. },
  236. format: (formatModel, value) => {
  237. formatModel.value["legend.backgroundColor"] = value?.type === 'color' ? value.color : 'none';
  238. },
  239. valueToForm: (value) => {
  240. return !value || value === 'none'
  241. ? {
  242. type: 'none'
  243. }
  244. : {
  245. type: "color",
  246. color: value.color,
  247. };
  248. },
  249. },
  250. {
  251. label: "阴影",
  252. prop: "legend.shadowBlur",
  253. type: "radioGroup",
  254. fieldProps: {
  255. options: [
  256. { label: "开启", value: true },
  257. { label: "关闭", value: false },
  258. ],
  259. },
  260. defaultValue: false,
  261. format: (formatModel, value) => {
  262. formatModel.value["legend.shadowBlur"] = value ? 10 : 0;
  263. formatModel.value["legend.shadowColor"] = "#000";
  264. },
  265. valueToForm: (value) => {
  266. return value ? true : false;
  267. },
  268. },
  269. ]
  270. : [];
  271. },
  272. },
  273. ],
  274. },
  275. /* 系列 */
  276. series: {
  277. label: "系列",
  278. prop: "series",
  279. type: "group",
  280. children: [
  281. {
  282. label: "配色",
  283. prop: "color",
  284. type: "colorScheme",
  285. defaultValue: colorPreset[0].color,
  286. },
  287. ],
  288. },
  289. /* X轴 */
  290. xAxis: {
  291. label: "X 轴",
  292. prop: "xAxis",
  293. type: "group",
  294. children: [
  295. {
  296. label: "类型",
  297. prop: "xAxis.type",
  298. type: "select",
  299. fieldProps: {
  300. options: [
  301. { label: "类目坐标轴", value: "category" },
  302. { label: "数值坐标轴", value: "value" },
  303. { label: "时间坐标轴", value: "time" },
  304. ],
  305. },
  306. defaultValue: "category",
  307. },
  308. {
  309. label: " ",
  310. prop: "xAxis.showName",
  311. type: "checkboxGroup",
  312. fieldProps: {
  313. options: [{ label: "显示轴标题", value: true }],
  314. },
  315. defaultValue: [true],
  316. format: (formatModel, value) => {
  317. formatModel.value["xAxis.showName"] = value?.length ? true : false;
  318. },
  319. valueToForm: (value) => {
  320. return value ? [true] : [];
  321. },
  322. },
  323. {
  324. label: "",
  325. prop: "",
  326. type: "dependency",
  327. name: ["xAxis.showName"],
  328. children: (model) => {
  329. return model["xAxis.showName"].length
  330. ? [
  331. {
  332. label: "标题内容",
  333. prop: "xAxis.name",
  334. type: "input",
  335. defaultValue: "X 轴标题",
  336. format: (formatModel, value) => {
  337. if (formatModel.value["xAxis.showName"]) {
  338. formatModel.value["xAxis.name"] = value;
  339. formatModel.value["grid.bottom"] = 40;
  340. } else {
  341. formatModel.value["xAxis.name"] = "";
  342. formatModel.value["grid.bottom"] = 20;
  343. }
  344. },
  345. },
  346. {
  347. label: "标题位置",
  348. prop: "xAxis.nameLocation",
  349. type: "position",
  350. defaultValue: "center",
  351. format: (formatModel, value: "left" | "center" | "right") => {
  352. const p = {
  353. left: "start",
  354. center: "middle",
  355. right: "end",
  356. };
  357. formatModel.value["xAxis.nameLocation"] = value
  358. ? p[value]
  359. : "middle";
  360. },
  361. valueToForm: (value) => {
  362. const p = {
  363. start: "left",
  364. middle: "center",
  365. end: "right",
  366. };
  367. return p[value];
  368. },
  369. },
  370. {
  371. label: "标题样式",
  372. prop: "xAxis.nameTextStyle",
  373. type: "fontStyle",
  374. defaultValue: {
  375. color: "#000000ff",
  376. size: 12,
  377. bold: false,
  378. italic: false,
  379. },
  380. format: (formatModel, value) => {
  381. formatModel.value["xAxis.nameTextStyle"] = {
  382. color: value.color,
  383. fontSize: value.size,
  384. fontWeight: value.bold ? "bold" : "normal",
  385. fontStyle: value.italic ? "italic" : "normal",
  386. };
  387. },
  388. valueToForm: (_, model) => {
  389. return {
  390. color: get(model, 'xAxis.nameTextStyle.color', '#000000ff'),
  391. size: get(model, 'xAxis.nameTextStyle.fontSize', 12),
  392. bold: get(model, 'xAxis.nameTextStyle.fontWeight') === 'bold',
  393. italic: get(model, 'xAxis.nameTextStyle.fontStyle') === 'italic',
  394. }
  395. }
  396. },
  397. ]
  398. : [];
  399. },
  400. },
  401. {
  402. label: "轴线",
  403. prop: "",
  404. type: "divider",
  405. },
  406. {
  407. label: "线宽",
  408. prop: "xAxis.axisLine.width",
  409. type: "inputNumber",
  410. fieldProps: {
  411. addonAfter: "px",
  412. },
  413. defaultValue: 1,
  414. },
  415. {
  416. label: "颜色",
  417. prop: "xAxis.axisLine.color",
  418. type: "colorSelect",
  419. defaultValue: "#ccc",
  420. },
  421. {
  422. label: "刻度",
  423. prop: "",
  424. type: "divider",
  425. },
  426. {
  427. label: " ",
  428. prop: "xAxis.axisTick.show",
  429. type: "checkboxGroup",
  430. fieldProps: {
  431. options: [{ label: "显示刻度", value: true }],
  432. },
  433. defaultValue: [true],
  434. format: (formatModel, value) => {
  435. formatModel.value["xAxis.axisTick.show"] = value?.length
  436. ? true
  437. : false;
  438. },
  439. valueToForm: (value) => {
  440. return value ? [true] : [];
  441. },
  442. },
  443. {
  444. label: "",
  445. prop: "",
  446. type: "dependency",
  447. name: ["xAxis.axisTick.show"],
  448. children: (model) => {
  449. return model["xAxis.axisTick.show"].length
  450. ? [
  451. {
  452. label: "刻度宽度",
  453. prop: "xAxis.axisTick.lineStyle.width",
  454. type: "inputNumber",
  455. fieldProps: {
  456. addonAfter: "px",
  457. },
  458. defaultValue: 5,
  459. },
  460. {
  461. label: "刻度颜色",
  462. prop: "xAxis.axisTick.lineStyle.color",
  463. type: "colorSelect",
  464. defaultValue: "#ccc",
  465. },
  466. ]
  467. : [];
  468. },
  469. },
  470. {
  471. label: "标签",
  472. prop: "",
  473. type: "divider",
  474. },
  475. {
  476. label: " ",
  477. prop: "xAxis.axisLabel.show",
  478. type: "checkboxGroup",
  479. fieldProps: {
  480. options: [{ label: "显示标签", value: true }],
  481. },
  482. defaultValue: [true],
  483. format: (formatModel, value) => {
  484. formatModel.value["xAxis.axisLabel.show"] = value?.length
  485. ? true
  486. : false;
  487. },
  488. valueToForm: (value) => {
  489. return value ? [true] : [];
  490. },
  491. },
  492. {
  493. label: "",
  494. prop: "",
  495. type: "dependency",
  496. name: ["xAxis.axisLabel.show"],
  497. children: (model) => {
  498. return model["xAxis.axisLabel.show"].length
  499. ? [
  500. {
  501. label: "样式",
  502. prop: "xAxis.axisLabel",
  503. type: "fontStyle",
  504. defaultValue: {
  505. color: "#000000ff",
  506. size: 12,
  507. bold: false,
  508. italic: false,
  509. },
  510. format: (formatModel, value) => {
  511. formatModel.value["xAxis.axisLabel.color"] = value?.color;
  512. formatModel.value["xAxis.axisLabel.fontSize"] = value.size;
  513. formatModel.value["xAxis.axisLabel.fontWeight"] = value.bold
  514. ? "bold"
  515. : "normal";
  516. formatModel.value["xAxis.axisLabel.fontStyle"] =
  517. value.italic ? "italic" : "normal";
  518. },
  519. valueToForm: (_, model) => {
  520. return {
  521. color: get(model, 'xAxis.axisLabel.color', '#000000ff'),
  522. size: get(model, 'xAxis.axisLabel.fontSize', 12),
  523. bold: get(model, 'xAxis.axisLabel.fontWeight') === 'bold',
  524. italic: get(model, 'xAxis.axisLabel.fontStyle') === 'italic',
  525. }
  526. }
  527. },
  528. ]
  529. : [];
  530. },
  531. },
  532. ],
  533. },
  534. /* Y 轴 */
  535. yAxis: {
  536. label: "Y 轴",
  537. prop: "yAxis",
  538. type: "group",
  539. children: [
  540. {
  541. label: " ",
  542. prop: "yAxis.show",
  543. type: "checkboxGroup",
  544. fieldProps: {
  545. options: [{ label: "显示轴标题", value: true }],
  546. },
  547. defaultValue: [],
  548. format: (formatModel, value) => {
  549. formatModel.value["yAxis.show"] = value?.length ? true : false;
  550. },
  551. valueToForm: (value) => {
  552. return value ? [true] : [];
  553. },
  554. },
  555. {
  556. label: "",
  557. prop: "",
  558. type: "dependency",
  559. name: ["yAxis.show"],
  560. children: (model) => {
  561. return model["yAxis.show"].length
  562. ? [
  563. {
  564. label: "标题内容",
  565. prop: "yAxis.name",
  566. type: "input",
  567. defaultValue: "Y 轴标题",
  568. format: (formatModel, value) => {
  569. if (formatModel.value["yAxis.show"]) {
  570. formatModel.value["yAxis.name"] = value;
  571. formatModel.value["grid.left"] = 40;
  572. } else {
  573. formatModel.value["yAxis.name"] = "";
  574. formatModel.value["grid.left"] = 20;
  575. }
  576. },
  577. },
  578. {
  579. label: "标题位置",
  580. prop: "yAxis.nameLocation",
  581. type: "position",
  582. defaultValue: "center",
  583. format: (formatModel, value: "left" | "center" | "right") => {
  584. const p = {
  585. left: "start",
  586. center: "middle",
  587. right: "end",
  588. };
  589. formatModel.value["yAxis.nameLocation"] = value
  590. ? p[value]
  591. : "middle";
  592. },
  593. valueToForm: (value) => {
  594. const p = {
  595. start: "left",
  596. middle: "center",
  597. end: "right",
  598. };
  599. return p[value];
  600. },
  601. },
  602. {
  603. label: "标题样式",
  604. prop: "yAxis.nameTextStyle",
  605. type: "fontStyle",
  606. defaultValue: {
  607. color: "#000000ff",
  608. size: 12,
  609. bold: false,
  610. italic: false,
  611. },
  612. format: (formatModel, value) => {
  613. formatModel.value["yAxis.nameTextStyle"] = {
  614. color: value.color,
  615. fontSize: value.size,
  616. fontWeight: value.bold ? "bold" : "normal",
  617. fontStyle: value.italic ? "italic" : "normal",
  618. };
  619. },
  620. valueToForm: (_, model) => {
  621. return {
  622. color: get(model, 'yAxis.nameTextStyle.color', '#000000ff'),
  623. size: get(model, 'yAxis.nameTextStyle.fontSize', 12),
  624. bold: get(model, 'yAxis.nameTextStyle.fontWeight') === 'bold',
  625. italic: get(model, 'yAxis.nameTextStyle.fontStyle') === 'italic',
  626. }
  627. }
  628. },
  629. ]
  630. : [];
  631. },
  632. },
  633. {
  634. label: "轴线",
  635. prop: "",
  636. type: "divider",
  637. },
  638. {
  639. label: "线宽",
  640. prop: "yAxis.axisLine.width",
  641. type: "inputNumber",
  642. fieldProps: {
  643. addonAfter: "px",
  644. },
  645. defaultValue: 1,
  646. },
  647. {
  648. label: "颜色",
  649. prop: "yAxis.axisLine.color",
  650. type: "colorSelect",
  651. defaultValue: "#ccc",
  652. },
  653. {
  654. label: "刻度",
  655. prop: "",
  656. type: "divider",
  657. },
  658. {
  659. label: " ",
  660. prop: "yAxis.axisTick.show",
  661. type: "checkboxGroup",
  662. fieldProps: {
  663. options: [{ label: "显示刻度", value: true }],
  664. },
  665. defaultValue: [true],
  666. format: (formatModel, value) => {
  667. formatModel.value["yAxis.axisTick.show"] = value?.length
  668. ? true
  669. : false;
  670. },
  671. valueToForm: (value) => {
  672. return value ? [true] : [];
  673. }
  674. },
  675. {
  676. label: "",
  677. prop: "",
  678. type: "dependency",
  679. name: ["yAxis.axisTick.show"],
  680. children: (model) => {
  681. return model["yAxis.axisTick.show"].length
  682. ? [
  683. {
  684. label: "刻度长度",
  685. prop: "yAxis.axisTick.lineStyle.width",
  686. type: "inputNumber",
  687. fieldProps: {
  688. addonAfter: "px",
  689. },
  690. defaultValue: 5,
  691. },
  692. {
  693. label: "刻度颜色",
  694. prop: "yAxis.axisTick.lineStyle.color",
  695. type: "colorSelect",
  696. defaultValue: "#ccc",
  697. },
  698. ]
  699. : [];
  700. },
  701. },
  702. {
  703. label: "标签",
  704. prop: "",
  705. type: "divider",
  706. },
  707. {
  708. label: " ",
  709. prop: "yAxis.axisLabel.show",
  710. type: "checkboxGroup",
  711. fieldProps: {
  712. options: [{ label: "显示标签", value: true }],
  713. },
  714. defaultValue: [true],
  715. format: (formatModel, value) => {
  716. formatModel.value["yAxis.axisLabel.show"] = value?.length
  717. ? true
  718. : false;
  719. },
  720. valueToForm: (value) => {
  721. return value ? [true] : [];
  722. }
  723. },
  724. {
  725. label: "",
  726. prop: "",
  727. type: "dependency",
  728. name: ["yAxis.axisLabel.show"],
  729. children: (model) => {
  730. return model["yAxis.axisLabel.show"].length
  731. ? [
  732. {
  733. label: "样式",
  734. prop: "yAxis.axisLabel",
  735. type: "fontStyle",
  736. defaultValue: {
  737. color: "#000000ff",
  738. size: 12,
  739. bold: false,
  740. italic: false,
  741. },
  742. format: (formatModel, value) => {
  743. formatModel.value["yAxis.axisLabel.color"] = value?.color;
  744. formatModel.value["yAxis.axisLabel.fontSize"] = value.size;
  745. formatModel.value["yAxis.axisLabel.fontWeight"] = value.bold
  746. ? "bold"
  747. : "normal";
  748. formatModel.value["yAxis.axisLabel.fontStyle"] =
  749. value.italic ? "italic" : "normal";
  750. },
  751. valueToForm: (_, model) => {
  752. return {
  753. color: get(model, 'yAxis.axisLabel.color', '#000000ff'),
  754. size: get(model, 'yAxis.axisLabel.fontSize', 12),
  755. bold: get(model, 'yAxis.axisLabel.fontWeight') === 'bold',
  756. italic: get(model, 'yAxis.axisLabel.fontStyle') === 'italic',
  757. }
  758. }
  759. },
  760. ]
  761. : [];
  762. },
  763. },
  764. ],
  765. },
  766. /* 提示 */
  767. tooltip: {
  768. label: "提示",
  769. prop: "tooltip",
  770. type: "group",
  771. children: [
  772. {
  773. label: " ",
  774. prop: "tooltip.show",
  775. type: "checkboxGroup",
  776. fieldProps: {
  777. options: [{ label: "提示可见", value: true }],
  778. },
  779. defaultValue: [true],
  780. format: (formatModel, value) => {
  781. formatModel.value["tooltip.show"] = value?.length ? true : false;
  782. },
  783. valueToForm: (value) => {
  784. return value ? [true] : [];
  785. }
  786. },
  787. {
  788. label: "",
  789. prop: "",
  790. type: "dependency",
  791. name: ["tooltip.show"],
  792. children: (model) => {
  793. return model["tooltip.show"].length
  794. ? [
  795. {
  796. label: "文本",
  797. prop: "tooltip.formatter",
  798. type: "checkboxGroup",
  799. fieldProps: {
  800. options: [
  801. { label: "分类名", value: "b" },
  802. { label: "系列名", value: "a" },
  803. { label: "数值", value: "c" },
  804. ],
  805. },
  806. defaultValue: ["b"],
  807. format: (formatModel, list) => {
  808. formatModel.value["tooltip.formatter"] = list.map((item) => `{${item}}`).join(" ");
  809. },
  810. valueToForm: (_, model) => {
  811. return get(model, 'tooltip.formatter')?.replace(/\{|\}/g, "")?.split(" ");
  812. }
  813. },
  814. {
  815. label: "格式化",
  816. prop: "tooltip.valueFormatter",
  817. type: "input",
  818. tip: "支持字符串模板和回调函数",
  819. defaultValue: "(value, dataIndex) => value",
  820. },
  821. {
  822. label: "样式",
  823. prop: "tooltip.textStyle",
  824. type: "fontStyle",
  825. defaultValue: {
  826. color: "#000000ff",
  827. size: 12,
  828. bold: false,
  829. italic: false,
  830. },
  831. format: (formatModel, value) => {
  832. formatModel.value["tooltip.textStyle"] = {
  833. color: value.color,
  834. fontSize: value.size,
  835. fontWeight: value.bold ? "bold" : "normal",
  836. fontStyle: value.italic ? "italic" : "normal",
  837. };
  838. },
  839. valueToForm: (_, model) => {
  840. return {
  841. color: get(model, 'tooltip.textStyle.color', '#000000ff'),
  842. size: get(model, 'tooltip.textStyle.fontSize', 12),
  843. bold: get(model, 'tooltip.textStyle.fontWeight') === 'bold',
  844. italic: get(model, 'tooltip.textStyle.fontStyle') === 'italic',
  845. }
  846. }
  847. },
  848. {
  849. label: "边框",
  850. prop: "",
  851. type: "divider",
  852. },
  853. {
  854. label: "线宽",
  855. prop: "tooltip.borderWidth",
  856. type: "inputNumber",
  857. fieldProps: {
  858. addonAfter: "px",
  859. },
  860. defaultValue: 1,
  861. },
  862. {
  863. label: "颜色",
  864. prop: "tooltip.borderColor",
  865. type: "colorSelect",
  866. defaultValue: "#ccc",
  867. },
  868. {
  869. label: "背景",
  870. prop: "",
  871. type: "divider",
  872. },
  873. {
  874. label: "填充",
  875. prop: "tooltip.backgroundColor",
  876. type: "backgroundSelect",
  877. fieldProps: {
  878. filterOptions: ["image"],
  879. },
  880. defaultValue: {
  881. type: "color",
  882. color: "#fff",
  883. },
  884. format: (formatModel, value) => {
  885. formatModel.value["tooltip.backgroundColor"] = value?.type === 'color' ? value.color : 'none';
  886. },
  887. valueToForm: (value) => {
  888. return !value || value === 'none'
  889. ? {
  890. type: 'none'
  891. }
  892. : {
  893. type: "color",
  894. color: value.color,
  895. };
  896. },
  897. },
  898. {
  899. label: "阴影",
  900. prop: "tooltip.extraCssText",
  901. type: "radioGroup",
  902. fieldProps: {
  903. options: [
  904. { label: "开启", value: true },
  905. { label: "关闭", value: false },
  906. ],
  907. },
  908. defaultValue: false,
  909. format: (formatModel, value) => {
  910. formatModel.value["tooltip.extraCssText"] = value
  911. ? "box-shadow: 0 0 3px rgba(0, 0, 0, 0.3);"
  912. : "";
  913. },
  914. valueToForm: (_, model) => {
  915. return get(model, 'tooltip.extraCssText') ? true : false;
  916. }
  917. },
  918. ]
  919. : [];
  920. },
  921. },
  922. ],
  923. },
  924. /* 标签 */
  925. label: {
  926. label: "标签",
  927. prop: "label",
  928. type: "group",
  929. children: [
  930. {
  931. label: " ",
  932. prop: "label.show",
  933. type: "checkboxGroup",
  934. fieldProps: {
  935. options: [{ label: "标签可见", value: true }],
  936. },
  937. defaultValue: [],
  938. format: (formatModel, value) => {
  939. formatModel.value["label.show"] = value?.length ? true : false;
  940. },
  941. valueToForm: (value) => {
  942. return value ? [true] : [];
  943. }
  944. },
  945. {
  946. label: "",
  947. prop: "",
  948. type: "dependency",
  949. name: ["label.show"],
  950. children: (model) => {
  951. return model["label.show"].length
  952. ? [
  953. {
  954. label: "文本",
  955. prop: "label.formatter",
  956. type: "checkboxGroup",
  957. fieldProps: {
  958. options: [
  959. { label: "分类名", value: "b" },
  960. { label: "系列名", value: "a" },
  961. { label: "数值", value: "c" },
  962. // { label: "百分比", value: "percent" },
  963. ],
  964. },
  965. defaultValue: ["a"],
  966. format: (formatModel, value) => {
  967. formatModel.value["label.formatter"] = `{${value}}`;
  968. },
  969. valueToForm: (_, model) => {
  970. return get(model, 'label.formatter')?.replace(/\{|\}/g, "")?.split(" ");
  971. }
  972. },
  973. {
  974. label: "样式",
  975. prop: "label.fontStyle",
  976. type: "fontStyle",
  977. defaultValue: {
  978. color: "#000000ff",
  979. size: 12,
  980. bold: false,
  981. italic: false,
  982. },
  983. format: (formatModel, value) => {
  984. formatModel.value["label.color"] = value?.color;
  985. formatModel.value["label.fontSize"] = value.size;
  986. formatModel.value["label.fontWeight"] = value.bold
  987. ? "bold"
  988. : "normal";
  989. formatModel.value["label.fontStyle"] = value.italic
  990. ? "italic"
  991. : "normal";
  992. },
  993. valueToForm: (_, model) => {
  994. return {
  995. color: get(model, 'label.color', '#000000ff'),
  996. size: get(model, 'label.fontSize', 12),
  997. bold: get(model, 'label.fontWeight') === 'bold',
  998. italic: get(model, 'label.fontStyle') === 'italic',
  999. }
  1000. }
  1001. },
  1002. {
  1003. label: "布局",
  1004. prop: "",
  1005. type: "divider",
  1006. },
  1007. {
  1008. label: "位置",
  1009. prop: "label.position",
  1010. type: "radioGroup",
  1011. fieldProps: {
  1012. options: [
  1013. { label: "顶部", value: "top" },
  1014. { label: "左侧", value: "left" },
  1015. { label: "右侧", value: "right" },
  1016. { label: "底部", value: "bottom" },
  1017. { label: "内部", value: "inside" },
  1018. { label: "内部左侧", value: "insideLeft" },
  1019. { label: "内部右侧", value: "insideRight" },
  1020. { label: "内部顶部", value: "insideTop" },
  1021. { label: "内部底部", value: "insideBottom" },
  1022. ],
  1023. },
  1024. defaultValue: "top",
  1025. },
  1026. {
  1027. label: "文本方向",
  1028. prop: "label.rotate",
  1029. type: "radioGroup",
  1030. fieldProps: {
  1031. options: [
  1032. { label: "水平", value: "horizontal" },
  1033. { label: "垂直", value: "vertical" },
  1034. ],
  1035. },
  1036. defaultValue: "horizontal",
  1037. format: (formatModel, value) => {
  1038. formatModel.value["label.rotate"] =
  1039. value === "horizontal" ? 0 : 90;
  1040. },
  1041. valueToForm: (value) => {
  1042. return value === 0 ? "horizontal" : "vertical";
  1043. },
  1044. },
  1045. {
  1046. label: "边框",
  1047. prop: "",
  1048. type: "divider",
  1049. },
  1050. {
  1051. label: "线宽",
  1052. prop: "label.borderWidth",
  1053. type: "inputNumber",
  1054. fieldProps: {
  1055. addonAfter: "px",
  1056. },
  1057. defaultValue: 0,
  1058. },
  1059. {
  1060. label: "颜色",
  1061. prop: "label.borderColor",
  1062. type: "colorSelect",
  1063. defaultValue: "#ccc",
  1064. },
  1065. {
  1066. label: "圆角",
  1067. prop: "label.borderRadius",
  1068. type: "inputNumber",
  1069. fieldProps: {
  1070. addonAfter: "px",
  1071. },
  1072. defaultValue: 0,
  1073. },
  1074. ]
  1075. : [];
  1076. },
  1077. },
  1078. ],
  1079. },
  1080. };