chartFormItemsMap.ts 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200
  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. format: (formatModel, value) => {
  164. if(['left', 'right'].includes(value)) {
  165. formatModel.value["legend.orient"] = 'vertical';
  166. } else {
  167. formatModel.value["legend.orient"] = 'horizontal';
  168. }
  169. switch(value) {
  170. case 'bottom':
  171. formatModel.value["legend.top"] = 'auto';
  172. formatModel.value["legend.right"] = 'auto';
  173. formatModel.value["legend.bottom"] = 8;
  174. formatModel.value["legend.left"] = 'center';
  175. break;
  176. case 'left':
  177. formatModel.value["legend.bottom"] = 'auto';
  178. formatModel.value["legend.right"] = 'auto';
  179. formatModel.value["legend.left"] = 8;
  180. formatModel.value["legend.top"] = 'center';
  181. break;
  182. case 'right':
  183. formatModel.value["legend.bottom"] = 'auto';
  184. formatModel.value["legend.left"] = 'auto';
  185. formatModel.value["legend.right"] = 8;
  186. formatModel.value["legend.top"] = 'center';
  187. break;
  188. default:
  189. formatModel.value["legend.bottom"] = 'auto';
  190. formatModel.value["legend.right"] = 'auto';
  191. formatModel.value["legend.top"] = 32;
  192. formatModel.value["legend.left"] = 'center';
  193. }
  194. },
  195. valueToForm: (value, model) => {
  196. if(get(model, 'legend.orient') === 'vertical') {
  197. return value === 'top' ? 'top' : value === 'bottom' ? 'bottom' : 'left';
  198. }
  199. if(get(model, 'legend.bottom') === 8 && get(model, 'legend.left') === 'center') {
  200. return 'bottom';
  201. }
  202. return 'top';
  203. },
  204. },
  205. {
  206. label: "样式",
  207. prop: "legend.textStyle",
  208. type: "fontStyle",
  209. defaultValue: {
  210. color: "#000000ff",
  211. size: 12,
  212. bold: false,
  213. italic: false,
  214. },
  215. format: (formatModel, value) => {
  216. formatModel.value["legend.textStyle"] = {
  217. color: value.color,
  218. fontSize: value.size,
  219. fontWeight: value.bold ? "bold" : "normal",
  220. fontStyle: value.italic ? "italic" : "normal",
  221. };
  222. },
  223. valueToForm: (_, model) => {
  224. return {
  225. color: get(model, 'legend.textStyle.color', '#000000ff'),
  226. size: get(model, 'legend.textStyle.fontSize', 12),
  227. bold: get(model, 'legend.textStyle.fontWeight') === 'bold',
  228. italic: get(model, 'legend.textStyle.fontStyle') === 'italic',
  229. }
  230. }
  231. },
  232. {
  233. label: "边框",
  234. prop: "",
  235. type: "divider",
  236. },
  237. {
  238. label: "线宽",
  239. prop: "legend.borderWidth",
  240. type: "inputNumber",
  241. fieldProps: {
  242. addonAfter: "px",
  243. },
  244. defaultValue: 0,
  245. },
  246. {
  247. label: "颜色",
  248. prop: "legend.borderColor",
  249. type: "colorSelect",
  250. defaultValue: "#ccc",
  251. },
  252. {
  253. label: "圆角",
  254. prop: "legend.borderRadius",
  255. type: "inputNumber",
  256. fieldProps: {
  257. addonAfter: "px",
  258. },
  259. defaultValue: 0,
  260. },
  261. {
  262. label: "背景",
  263. prop: "",
  264. type: "divider",
  265. },
  266. {
  267. label: "背景",
  268. prop: "legend.backgroundColor",
  269. type: "backgroundSelect",
  270. fieldProps: {
  271. filterOptions: ["image"],
  272. },
  273. defaultValue: {
  274. type: "color",
  275. color: "#fff",
  276. },
  277. format: (formatModel, value) => {
  278. formatModel.value["legend.backgroundColor"] = value?.type === 'color' ? value.color : 'none';
  279. },
  280. valueToForm: (value) => {
  281. return !value || value === 'none'
  282. ? {
  283. type: 'none'
  284. }
  285. : {
  286. type: "color",
  287. color: value.color,
  288. };
  289. },
  290. },
  291. {
  292. label: "阴影",
  293. prop: "legend.shadowBlur",
  294. type: "radioGroup",
  295. fieldProps: {
  296. options: [
  297. { label: "开启", value: true },
  298. { label: "关闭", value: false },
  299. ],
  300. },
  301. defaultValue: false,
  302. format: (formatModel, value) => {
  303. if(value) {
  304. formatModel.value["legend.shadowBlur"] = 10;
  305. formatModel.value["legend.shadowColor"] = formatModel.value['legend.backgroundColor'] || '#000000ff';
  306. formatModel.value["legend.shadowOffsetX"] = 3;
  307. formatModel.value["legend.shadowOffsetY"] = 3;
  308. } else {
  309. formatModel.value["legend.shadowBlur"] = 0;
  310. formatModel.value["legend.shadowColor"] = "transparent";
  311. formatModel.value["legend.shadowOffsetX"] = 0;
  312. formatModel.value["legend.shadowOffsetY"] = 0;
  313. }
  314. },
  315. valueToForm: (value) => {
  316. return value ? true : false;
  317. },
  318. },
  319. ]
  320. : [];
  321. },
  322. },
  323. ],
  324. },
  325. /* 系列 */
  326. series: {
  327. label: "系列",
  328. prop: "series",
  329. type: "group",
  330. children: [
  331. {
  332. label: "配色",
  333. prop: "color",
  334. type: "colorScheme",
  335. defaultValue: colorPreset[0].color,
  336. },
  337. ],
  338. },
  339. /* X轴 */
  340. xAxis: {
  341. label: "X 轴",
  342. prop: "xAxis",
  343. type: "group",
  344. children: [
  345. {
  346. label: "类型",
  347. prop: "xAxis.type",
  348. type: "select",
  349. fieldProps: {
  350. options: [
  351. { label: "类目坐标轴", value: "category" },
  352. { label: "数值坐标轴", value: "value" },
  353. { label: "时间坐标轴", value: "time" },
  354. ],
  355. },
  356. defaultValue: "category",
  357. },
  358. {
  359. label: " ",
  360. prop: "xAxis.showName",
  361. type: "checkboxGroup",
  362. fieldProps: {
  363. options: [{ label: "显示轴标题", value: true }],
  364. },
  365. defaultValue: [true],
  366. format: (formatModel, value) => {
  367. if(value?.length) {
  368. formatModel.value["xAxis.showName"] = true;
  369. formatModel.value["xAxis.name"] = 'X轴标题';
  370. formatModel.value["xAxis.nameGap"] = 25;
  371. } else {
  372. formatModel.value["xAxis.showName"] = false;
  373. formatModel.value["xAxis.name"] = "";
  374. formatModel.value["xAxis.nameGap"] = 15;
  375. formatModel.value["xAxis.nameGap"] = 15;
  376. }
  377. },
  378. valueToForm: (value) => {
  379. return value ? [true] : [];
  380. },
  381. },
  382. {
  383. label: "",
  384. prop: "",
  385. type: "dependency",
  386. name: ["xAxis.showName"],
  387. children: (model) => {
  388. return model["xAxis.showName"].length
  389. ? [
  390. {
  391. label: "标题内容",
  392. prop: "xAxis.name",
  393. type: "input",
  394. defaultValue: "X 轴标题",
  395. format: (formatModel, value) => {
  396. if (formatModel.value["xAxis.showName"]) {
  397. formatModel.value["xAxis.name"] = value;
  398. formatModel.value["xAxis.nameGap"] = 25;
  399. }
  400. },
  401. valueToForm: (value) => {
  402. return value || "X 轴标题";
  403. }
  404. },
  405. {
  406. label: "标题位置",
  407. prop: "xAxis.nameLocation",
  408. type: "position",
  409. defaultValue: "center",
  410. format: (formatModel, value: "left" | "center" | "right") => {
  411. const p = {
  412. left: "start",
  413. center: "middle",
  414. right: "end",
  415. };
  416. formatModel.value["xAxis.nameLocation"] = value
  417. ? p[value]
  418. : "middle";
  419. },
  420. valueToForm: (value: 'start' | 'middle' | 'end') => {
  421. const p = {
  422. start: "left",
  423. middle: "center",
  424. end: "right",
  425. };
  426. return p[value] || "center";
  427. },
  428. },
  429. {
  430. label: "标题样式",
  431. prop: "xAxis.nameTextStyle",
  432. type: "fontStyle",
  433. defaultValue: {
  434. color: "#000000ff",
  435. size: 12,
  436. bold: false,
  437. italic: false,
  438. },
  439. format: (formatModel, value) => {
  440. formatModel.value["xAxis.nameTextStyle"] = {
  441. color: value.color,
  442. fontSize: value.size,
  443. fontWeight: value.bold ? "bold" : "normal",
  444. fontStyle: value.italic ? "italic" : "normal",
  445. };
  446. },
  447. valueToForm: (value) => {
  448. return {
  449. color: value?.color || '#000000ff',
  450. size: value?.fontSize || 12,
  451. bold: value?.fontWeight === 'bold' || false,
  452. italic: value?.fontStyle === 'italic' || false,
  453. }
  454. }
  455. },
  456. ]
  457. : [];
  458. },
  459. },
  460. {
  461. label: "轴线",
  462. prop: "",
  463. type: "divider",
  464. },
  465. {
  466. label: "线宽",
  467. prop: "xAxis.axisLine.lineStyle.width",
  468. type: "inputNumber",
  469. fieldProps: {
  470. addonAfter: "px",
  471. },
  472. defaultValue: 1,
  473. },
  474. {
  475. label: "颜色",
  476. prop: "xAxis.axisLine.lineStyle.color",
  477. type: "colorSelect",
  478. defaultValue: "#ccc",
  479. },
  480. {
  481. label: "刻度",
  482. prop: "",
  483. type: "divider",
  484. },
  485. {
  486. label: " ",
  487. prop: "xAxis.axisTick.show",
  488. type: "checkboxGroup",
  489. fieldProps: {
  490. options: [{ label: "显示刻度", value: true }],
  491. },
  492. defaultValue: [true],
  493. format: (formatModel, value) => {
  494. formatModel.value["xAxis.axisTick.show"] = value?.length
  495. ? true
  496. : false;
  497. },
  498. valueToForm: (value) => {
  499. return value ? [true] : [];
  500. },
  501. },
  502. {
  503. label: "",
  504. prop: "",
  505. type: "dependency",
  506. name: ["xAxis.axisTick.show"],
  507. children: (model) => {
  508. return model["xAxis.axisTick.show"].length
  509. ? [
  510. {
  511. label: "刻度宽度",
  512. prop: "xAxis.axisTick.lineStyle.width",
  513. type: "inputNumber",
  514. fieldProps: {
  515. addonAfter: "px",
  516. },
  517. defaultValue: 5,
  518. },
  519. {
  520. label: "刻度颜色",
  521. prop: "xAxis.axisTick.lineStyle.color",
  522. type: "colorSelect",
  523. defaultValue: "#ccc",
  524. },
  525. ]
  526. : [];
  527. },
  528. },
  529. {
  530. label: "标签",
  531. prop: "",
  532. type: "divider",
  533. },
  534. {
  535. label: " ",
  536. prop: "xAxis.axisLabel.show",
  537. type: "checkboxGroup",
  538. fieldProps: {
  539. options: [{ label: "显示标签", value: true }],
  540. },
  541. defaultValue: [true],
  542. format: (formatModel, value) => {
  543. formatModel.value["xAxis.axisLabel.show"] = value?.length
  544. ? true
  545. : false;
  546. },
  547. valueToForm: (value) => {
  548. return value ? [true] : [];
  549. },
  550. },
  551. {
  552. label: "",
  553. prop: "",
  554. type: "dependency",
  555. name: ["xAxis.axisLabel.show"],
  556. children: (model) => {
  557. return model["xAxis.axisLabel.show"].length
  558. ? [
  559. {
  560. label: "样式",
  561. prop: "xAxis.axisLabel",
  562. type: "fontStyle",
  563. defaultValue: {
  564. color: "#000000ff",
  565. size: 12,
  566. bold: false,
  567. italic: false,
  568. },
  569. format: (formatModel, value) => {
  570. formatModel.value["xAxis.axisLabel.color"] = value?.color;
  571. formatModel.value["xAxis.axisLabel.fontSize"] = value.size;
  572. formatModel.value["xAxis.axisLabel.fontWeight"] = value.bold
  573. ? "bold"
  574. : "normal";
  575. formatModel.value["xAxis.axisLabel.fontStyle"] =
  576. value.italic ? "italic" : "normal";
  577. },
  578. valueToForm: (_, model) => {
  579. return {
  580. color: get(model, 'xAxis.axisLabel.color', '#000000ff'),
  581. size: get(model, 'xAxis.axisLabel.fontSize', 12),
  582. bold: get(model, 'xAxis.axisLabel.fontWeight') === 'bold',
  583. italic: get(model, 'xAxis.axisLabel.fontStyle') === 'italic',
  584. }
  585. }
  586. },
  587. ]
  588. : [];
  589. },
  590. },
  591. ],
  592. },
  593. /* Y 轴 */
  594. yAxis: {
  595. label: "Y 轴",
  596. prop: "yAxis",
  597. type: "group",
  598. children: [
  599. {
  600. label: " ",
  601. prop: "yAxis.showName",
  602. type: "checkboxGroup",
  603. fieldProps: {
  604. options: [{ label: "显示轴标题", value: true }],
  605. },
  606. defaultValue: [],
  607. format: (formatModel, value) => {
  608. if(value?.length) {
  609. formatModel.value["yAxis.showName"] = true;
  610. formatModel.value["yAxis.name"] = 'Y轴标题';
  611. formatModel.value["yAxis.nameGap"] = 25;
  612. } else {
  613. formatModel.value["yAxis.showName"] = false;
  614. formatModel.value["yAxis.name"] = "";
  615. formatModel.value["yAxis.nameGap"] = 15;
  616. }
  617. },
  618. valueToForm: (value) => {
  619. return value ? [true] : [];
  620. },
  621. },
  622. {
  623. label: "",
  624. prop: "",
  625. type: "dependency",
  626. name: ["yAxis.showName"],
  627. children: (model) => {
  628. return model["yAxis.showName"].length
  629. ? [
  630. {
  631. label: "标题内容",
  632. prop: "yAxis.name",
  633. type: "input",
  634. defaultValue: "Y 轴标题",
  635. format: (formatModel, value) => {
  636. if (formatModel.value["yAxis.showName"]) {
  637. formatModel.value["yAxis.name"] = value;
  638. formatModel.value["yAxis.nameGap"] = 25;
  639. } else {
  640. formatModel.value["yAxis.name"] = "";
  641. formatModel.value["yAxis.nameGap"] = 15;
  642. }
  643. },
  644. valueToForm: (value) => {
  645. return value || "Y 轴标题";
  646. }
  647. },
  648. {
  649. label: "标题位置",
  650. prop: "yAxis.nameLocation",
  651. type: "position",
  652. defaultValue: "center",
  653. format: (formatModel, value: "left" | "center" | "right") => {
  654. const p = {
  655. left: "start",
  656. center: "middle",
  657. right: "end",
  658. };
  659. formatModel.value["yAxis.nameLocation"] = value
  660. ? p[value]
  661. : "middle";
  662. },
  663. valueToForm: (value: "start" | "middle" | "end") => {
  664. const p = {
  665. start: "left",
  666. middle: "center",
  667. end: "right",
  668. };
  669. return p[value] || 'center ';
  670. },
  671. },
  672. {
  673. label: "标题样式",
  674. prop: "yAxis.nameTextStyle",
  675. type: "fontStyle",
  676. defaultValue: {
  677. color: "#FFFFFFFF",
  678. size: 12,
  679. bold: false,
  680. italic: false,
  681. },
  682. format: (formatModel, value) => {
  683. formatModel.value["yAxis.nameTextStyle"] = {
  684. color: value.color,
  685. fontSize: value.size,
  686. fontWeight: value.bold ? "bold" : "normal",
  687. fontStyle: value.italic ? "italic" : "normal",
  688. };
  689. },
  690. valueToForm: (value) => {
  691. return {
  692. color: value?.color || '#000000ff',
  693. size: value?.fontSize || 12,
  694. bold: value?.fontWeight === 'bold' || false,
  695. italic: value?.fontStyle === 'italic' || false,
  696. }
  697. }
  698. },
  699. ]
  700. : [];
  701. },
  702. },
  703. {
  704. label: "轴线",
  705. prop: "",
  706. type: "divider",
  707. },
  708. {
  709. label: " ",
  710. prop: "yAxis.axisLine.show",
  711. type: "checkboxGroup",
  712. fieldProps: {
  713. options: [{ label: "显示轴线", value: true }],
  714. },
  715. defaultValue: [true],
  716. format: (formatModel, value) => {
  717. formatModel.value["yAxis.axisLine.show"] = value?.length
  718. ? true
  719. : false;
  720. },
  721. valueToForm: (value) => {
  722. return value ? [true] : [];
  723. }
  724. },
  725. {
  726. label: "",
  727. prop: "",
  728. type: "dependency",
  729. name: ["yAxis.axisLine.show"],
  730. children: (model) => {
  731. return model["yAxis.axisLine.show"].length
  732. ? [
  733. {
  734. label: "线宽",
  735. prop: "yAxis.axisLine.lineStyle.width",
  736. type: "inputNumber",
  737. fieldProps: {
  738. addonAfter: "px",
  739. },
  740. defaultValue: 1,
  741. },
  742. {
  743. label: "颜色",
  744. prop: "yAxis.axisLine.lineStyle.color",
  745. type: "colorSelect",
  746. defaultValue: "#ccc",
  747. },
  748. ]
  749. : [];
  750. }
  751. },
  752. {
  753. label: "刻度",
  754. prop: "",
  755. type: "divider",
  756. },
  757. {
  758. label: " ",
  759. prop: "yAxis.axisTick.show",
  760. type: "checkboxGroup",
  761. fieldProps: {
  762. options: [{ label: "显示刻度", value: true }],
  763. },
  764. defaultValue: [true],
  765. format: (formatModel, value) => {
  766. formatModel.value["yAxis.axisTick.show"] = value?.length
  767. ? true
  768. : false;
  769. },
  770. valueToForm: (value) => {
  771. return value ? [true] : [];
  772. }
  773. },
  774. {
  775. label: "",
  776. prop: "",
  777. type: "dependency",
  778. name: ["yAxis.axisTick.show"],
  779. children: (model) => {
  780. return model["yAxis.axisTick.show"].length
  781. ? [
  782. {
  783. label: "刻度长度",
  784. prop: "yAxis.axisTick.lineStyle.width",
  785. type: "inputNumber",
  786. fieldProps: {
  787. addonAfter: "px",
  788. },
  789. defaultValue: 5,
  790. },
  791. {
  792. label: "刻度颜色",
  793. prop: "yAxis.axisTick.lineStyle.color",
  794. type: "colorSelect",
  795. defaultValue: "#ccc",
  796. },
  797. ]
  798. : [];
  799. },
  800. },
  801. {
  802. label: "标签",
  803. prop: "",
  804. type: "divider",
  805. },
  806. {
  807. label: " ",
  808. prop: "yAxis.axisLabel.show",
  809. type: "checkboxGroup",
  810. fieldProps: {
  811. options: [{ label: "显示标签", value: true }],
  812. },
  813. defaultValue: [true],
  814. format: (formatModel, value) => {
  815. formatModel.value["yAxis.axisLabel.show"] = value?.length
  816. ? true
  817. : false;
  818. },
  819. valueToForm: (value) => {
  820. return value ? [true] : [];
  821. }
  822. },
  823. {
  824. label: "",
  825. prop: "",
  826. type: "dependency",
  827. name: ["yAxis.axisLabel.show"],
  828. children: (model) => {
  829. return model["yAxis.axisLabel.show"].length
  830. ? [
  831. {
  832. label: "样式",
  833. prop: "yAxis.axisLabel",
  834. type: "fontStyle",
  835. defaultValue: {
  836. color: "#000000ff",
  837. size: 12,
  838. bold: false,
  839. italic: false,
  840. },
  841. format: (formatModel, value) => {
  842. formatModel.value["yAxis.axisLabel.color"] = value?.color;
  843. formatModel.value["yAxis.axisLabel.fontSize"] = value.size;
  844. formatModel.value["yAxis.axisLabel.fontWeight"] = value.bold
  845. ? "bold"
  846. : "normal";
  847. formatModel.value["yAxis.axisLabel.fontStyle"] =
  848. value.italic ? "italic" : "normal";
  849. },
  850. valueToForm: (_, model) => {
  851. return {
  852. color: get(model, 'yAxis.axisLabel.color', '#000000ff'),
  853. size: get(model, 'yAxis.axisLabel.fontSize', 12),
  854. bold: get(model, 'yAxis.axisLabel.fontWeight') === 'bold',
  855. italic: get(model, 'yAxis.axisLabel.fontStyle') === 'italic',
  856. }
  857. }
  858. },
  859. {
  860. label: '旋转角度',
  861. prop: "yAxis.axisLabel.rotate",
  862. type: "inputNumber",
  863. fieldProps: {
  864. addonAfter: "°",
  865. min: -90,
  866. max: 90,
  867. step: 1
  868. },
  869. }
  870. ]
  871. : [];
  872. },
  873. },
  874. ],
  875. },
  876. /* 提示 */
  877. tooltip: {
  878. label: "提示",
  879. prop: "tooltip",
  880. type: "group",
  881. children: [
  882. {
  883. label: " ",
  884. prop: "tooltip.show",
  885. type: "checkboxGroup",
  886. fieldProps: {
  887. options: [{ label: "提示可见", value: true }],
  888. },
  889. defaultValue: [true],
  890. format: (formatModel, value) => {
  891. formatModel.value["tooltip.show"] = value?.length ? true : false;
  892. },
  893. valueToForm: (value) => {
  894. return value ? [true] : [];
  895. }
  896. },
  897. {
  898. label: "",
  899. prop: "",
  900. type: "dependency",
  901. name: ["tooltip.show"],
  902. children: (model) => {
  903. return model["tooltip.show"].length
  904. ? [
  905. {
  906. label: "文本",
  907. prop: "tooltip.formatter",
  908. type: "checkboxGroup",
  909. fieldProps: {
  910. options: [
  911. { label: "分类名", value: "b" },
  912. { label: "系列名", value: "a" },
  913. { label: "数值", value: "c" },
  914. ],
  915. },
  916. defaultValue: ["b"],
  917. format: (formatModel, list) => {
  918. formatModel.value["tooltip.formatter"] = list.map((item: any) => `{${item}}`).join(" ");
  919. },
  920. valueToForm: (_, model) => {
  921. return get(model, 'tooltip.formatter')?.replace(/\{|\}/g, "")?.split(" ");
  922. }
  923. },
  924. // {
  925. // label: "格式化",
  926. // prop: "tooltip.valueFormatter",
  927. // type: "input",
  928. // tip: "支持字符串模板和回调函数",
  929. // defaultValue: "(value, dataIndex) => value",
  930. // },
  931. {
  932. label: "样式",
  933. prop: "tooltip.textStyle",
  934. type: "fontStyle",
  935. defaultValue: {
  936. color: "#000000ff",
  937. size: 12,
  938. bold: false,
  939. italic: false,
  940. },
  941. format: (formatModel, value) => {
  942. formatModel.value["tooltip.textStyle"] = {
  943. color: value.color,
  944. fontSize: value.size,
  945. fontWeight: value.bold ? "bold" : "normal",
  946. fontStyle: value.italic ? "italic" : "normal",
  947. };
  948. },
  949. valueToForm: (_, model) => {
  950. return {
  951. color: get(model, 'tooltip.textStyle.color', '#000000ff'),
  952. size: get(model, 'tooltip.textStyle.fontSize', 12),
  953. bold: get(model, 'tooltip.textStyle.fontWeight') === 'bold',
  954. italic: get(model, 'tooltip.textStyle.fontStyle') === 'italic',
  955. }
  956. }
  957. },
  958. {
  959. label: "边框",
  960. prop: "",
  961. type: "divider",
  962. },
  963. {
  964. label: "线宽",
  965. prop: "tooltip.borderWidth",
  966. type: "inputNumber",
  967. fieldProps: {
  968. addonAfter: "px",
  969. },
  970. defaultValue: 1,
  971. },
  972. {
  973. label: "颜色",
  974. prop: "tooltip.borderColor",
  975. type: "colorSelect",
  976. defaultValue: "#ccc",
  977. },
  978. {
  979. label: "圆角",
  980. prop: "tooltip.borderRadius",
  981. type: "inputNumber",
  982. fieldProps: {
  983. addonAfter: "px",
  984. },
  985. defaultValue: 4,
  986. },
  987. {
  988. label: "背景",
  989. prop: "",
  990. type: "divider",
  991. },
  992. {
  993. label: "填充",
  994. prop: "tooltip.backgroundColor",
  995. type: "backgroundSelect",
  996. fieldProps: {
  997. filterOptions: ["image"],
  998. },
  999. defaultValue: {
  1000. type: "color",
  1001. color: "#fff",
  1002. },
  1003. format: (formatModel, value) => {
  1004. formatModel.value["tooltip.backgroundColor"] = value?.type === 'color' ? value.color : 'none';
  1005. },
  1006. valueToForm: (value) => {
  1007. return !value || value === 'none'
  1008. ? {
  1009. type: 'none'
  1010. }
  1011. : {
  1012. type: "color",
  1013. color: value,
  1014. };
  1015. },
  1016. },
  1017. {
  1018. label: "阴影",
  1019. prop: "tooltip.extraCssText",
  1020. type: "radioGroup",
  1021. fieldProps: {
  1022. options: [
  1023. { label: "开启", value: true },
  1024. { label: "关闭", value: false },
  1025. ],
  1026. },
  1027. defaultValue: false,
  1028. format: (formatModel, value) => {
  1029. formatModel.value["tooltip.extraCssText"] = value
  1030. ? "box-shadow: 0 0 3px rgba(0, 0, 0, 0.3);"
  1031. : "";
  1032. },
  1033. valueToForm: (_, model) => {
  1034. return get(model, 'tooltip.extraCssText') ? true : false;
  1035. }
  1036. },
  1037. ]
  1038. : [];
  1039. },
  1040. },
  1041. ],
  1042. },
  1043. /* 标签 */
  1044. label: {
  1045. label: "标签",
  1046. prop: "label",
  1047. type: "group",
  1048. children: [
  1049. {
  1050. label: " ",
  1051. prop: "label.show",
  1052. type: "checkboxGroup",
  1053. fieldProps: {
  1054. options: [{ label: "标签可见", value: true }],
  1055. },
  1056. defaultValue: [],
  1057. format: (formatModel, value) => {
  1058. formatModel.value["label.show"] = value?.length ? true : false;
  1059. },
  1060. valueToForm: (value) => {
  1061. return value ? [true] : [];
  1062. }
  1063. },
  1064. {
  1065. label: "",
  1066. prop: "",
  1067. type: "dependency",
  1068. name: ["label.show"],
  1069. children: (model) => {
  1070. return model["label.show"].length
  1071. ? [
  1072. {
  1073. label: "文本",
  1074. prop: "label.formatter",
  1075. type: "checkboxGroup",
  1076. fieldProps: {
  1077. options: [
  1078. { label: "分类名", value: "b" },
  1079. { label: "系列名", value: "a" },
  1080. { label: "数值", value: "c" },
  1081. // { label: "百分比", value: "percent" },
  1082. ],
  1083. },
  1084. defaultValue: ["a"],
  1085. format: (formatModel, value) => {
  1086. formatModel.value["label.formatter"] = `{${value}}`;
  1087. },
  1088. valueToForm: (_, model) => {
  1089. return get(model, 'label.formatter')?.replace(/\{|\}/g, "")?.split(" ");
  1090. }
  1091. },
  1092. {
  1093. label: "样式",
  1094. prop: "label.fontStyle",
  1095. type: "fontStyle",
  1096. defaultValue: {
  1097. color: "#000000ff",
  1098. size: 12,
  1099. bold: false,
  1100. italic: false,
  1101. },
  1102. format: (formatModel, value) => {
  1103. formatModel.value["label.color"] = value?.color;
  1104. formatModel.value["label.fontSize"] = value.size;
  1105. formatModel.value["label.fontWeight"] = value.bold
  1106. ? "bold"
  1107. : "normal";
  1108. formatModel.value["label.fontStyle"] = value.italic
  1109. ? "italic"
  1110. : "normal";
  1111. },
  1112. valueToForm: (_, model) => {
  1113. return {
  1114. color: get(model, 'label.color', '#000000ff'),
  1115. size: get(model, 'label.fontSize', 12),
  1116. bold: get(model, 'label.fontWeight') === 'bold',
  1117. italic: get(model, 'label.fontStyle') === 'italic',
  1118. }
  1119. }
  1120. },
  1121. {
  1122. label: "布局",
  1123. prop: "",
  1124. type: "divider",
  1125. },
  1126. {
  1127. label: "位置",
  1128. prop: "label.position",
  1129. type: "radioGroup",
  1130. fieldProps: {
  1131. options: [
  1132. { label: "顶部", value: "top" },
  1133. { label: "左侧", value: "left" },
  1134. { label: "右侧", value: "right" },
  1135. { label: "底部", value: "bottom" },
  1136. { label: "内部", value: "inside" },
  1137. { label: "内部左侧", value: "insideLeft" },
  1138. { label: "内部右侧", value: "insideRight" },
  1139. { label: "内部顶部", value: "insideTop" },
  1140. { label: "内部底部", value: "insideBottom" },
  1141. ],
  1142. },
  1143. defaultValue: "top",
  1144. },
  1145. {
  1146. label: "文本方向",
  1147. prop: "label.rotate",
  1148. type: "radioGroup",
  1149. fieldProps: {
  1150. options: [
  1151. { label: "水平", value: "horizontal" },
  1152. { label: "垂直", value: "vertical" },
  1153. ],
  1154. },
  1155. defaultValue: "horizontal",
  1156. format: (formatModel, value) => {
  1157. formatModel.value["label.rotate"] =
  1158. value === "horizontal" ? 0 : 90;
  1159. },
  1160. valueToForm: (value) => {
  1161. return value === 0 ? "horizontal" : "vertical";
  1162. },
  1163. },
  1164. {
  1165. label: "边框",
  1166. prop: "",
  1167. type: "divider",
  1168. },
  1169. {
  1170. label: "线宽",
  1171. prop: "label.borderWidth",
  1172. type: "inputNumber",
  1173. fieldProps: {
  1174. addonAfter: "px",
  1175. },
  1176. defaultValue: 0,
  1177. },
  1178. {
  1179. label: "颜色",
  1180. prop: "label.borderColor",
  1181. type: "colorSelect",
  1182. defaultValue: "#ccc",
  1183. },
  1184. {
  1185. label: "圆角",
  1186. prop: "label.borderRadius",
  1187. type: "inputNumber",
  1188. fieldProps: {
  1189. addonAfter: "px",
  1190. },
  1191. defaultValue: 0,
  1192. },
  1193. ]
  1194. : [];
  1195. },
  1196. },
  1197. ],
  1198. },
  1199. };