1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081 |
- import { IFormItem } from "../../cusForm";
- import { colorPreset } from "./index";
- import { get } from "lodash-es";
- /**
- * 用于快速配置图表配置项
- *
- * prop: 图表option的路径
- * format:转换数据
- *
- * */
- export const chartFormItemsMap: Record<string, IFormItem> = {
- /* 标题 */
- title: {
- label: "标题",
- prop: "title",
- type: "group",
- children: [
- {
- label: " ",
- prop: "title.show",
- type: "checkboxGroup",
- fieldProps: {
- options: [{ label: "标题可见", value: true }],
- },
- defaultValue: [],
- format: (formatModel, value) => {
- formatModel.value["title.show"] = value?.length ? true : false;
- },
- valueToForm: (value) => {
- return value ? [true] : [];
- }
- },
- {
- type: "dependency",
- label: "",
- prop: "",
- name: ["title.show"],
- children: (model) => {
- return model["title.show"].length
- ? [
- {
- label: "文本",
- prop: "title.text",
- type: "input",
- defaultValue: "图表标题",
- },
- {
- label: "位置",
- prop: "title.left",
- type: "position",
- defaultValue: "center",
- },
- {
- label: "样式",
- prop: "title.textStyle",
- type: "fontStyle",
- defaultValue: {
- color: "#ffffffff",
- size: 18,
- bold: true,
- italic: false,
- },
- format: (formatModel, value) => {
- formatModel.value["title.textStyle"] = {
- color: value.color,
- fontSize: value.size,
- fontWeight: value.bold ? "bold" : "normal",
- fontStyle: value.italic ? "italic" : "normal",
- };
- },
- valueToForm: (_, model) => {
- return {
- color: get(model, 'title.textStyle.color', '#FFFFFF'),
- size: get(model, 'title.textStyle.size', 16),
- bold: get(model, 'title.textStyle.fontWeight') === 'bold',
- italic: get(model, 'title.textStyle.fontStyle') === 'italic',
- }
- }
- },
- {
- label: "背景",
- prop: "",
- type: "divider",
- },
- {
- label: "填充",
- prop: "title.backgroundColor",
- type: "backgroundSelect",
- fieldProps: {
- filterOptions: ["image"],
- },
- defaultValue: {
- type: "color",
- color: "#FFFFFF00",
- },
- format: (formatModel, value) => {
- formatModel.value["title.backgroundColor"] = value?.type === 'color' ? value.color : 'none';
- },
- valueToForm: (value) => {
- return !value || value === 'none'
- ? {
- type: 'none',
- color: '#000000ff'
- }
- : {
- type: "color",
- color: value.color,
- };
- },
- },
- {
- label: "圆角",
- prop: "title.borderRadius",
- type: "inputNumber",
- fieldProps: {
- addonAfter: "px",
- },
- defaultValue: 0,
- },
- ]
- : [];
- },
- },
- ],
- },
- /* 图例 */
- legend: {
- label: "图例",
- prop: "legend",
- type: "group",
- children: [
- {
- label: " ",
- prop: "legend.show",
- type: "checkboxGroup",
- fieldProps: {
- options: [{ label: "图例可见", value: true }],
- },
- defaultValue: [true],
- format: (formatModel, value) => {
- formatModel.value["legend.show"] = value?.length ? true : false;
- },
- valueToForm: (value) => {
- return value ? [true] : [];
- },
- },
- {
- type: "dependency",
- label: "",
- prop: "",
- name: ["legend.show"],
- children: (model) => {
- return model["legend.show"].length
- ? [
- {
- label: "位置",
- prop: "legend.position",
- type: "position",
- fieldProps: {
- type: "round",
- },
- defaultValue: "top",
- },
- {
- label: "样式",
- prop: "legend.textStyle",
- type: "fontStyle",
- defaultValue: {
- color: "#000000ff",
- size: 12,
- bold: false,
- italic: false,
- },
- format: (formatModel, value) => {
- formatModel.value["legend.textStyle"] = {
- color: value.color,
- fontSize: value.size,
- fontWeight: value.bold ? "bold" : "normal",
- fontStyle: value.italic ? "italic" : "normal",
- };
- },
- valueToForm: (_, model) => {
- return {
- color: get(model, 'legend.textStyle.color', '#000000ff'),
- size: get(model, 'legend.textStyle.fontSize', 12),
- bold: get(model, 'legend.textStyle.fontWeight') === 'bold',
- italic: get(model, 'legend.textStyle.fontStyle') === 'italic',
- }
- }
- },
- {
- label: "边框",
- prop: "",
- type: "divider",
- },
- {
- label: "线宽",
- prop: "legend.borderWidth",
- type: "inputNumber",
- fieldProps: {
- addonAfter: "px",
- },
- defaultValue: 0,
- },
- {
- label: "颜色",
- prop: "legend.borderColor",
- type: "colorSelect",
- defaultValue: "#ccc",
- },
- {
- label: "圆角",
- prop: "legend.borderRadius",
- type: "inputNumber",
- fieldProps: {
- addonAfter: "px",
- },
- defaultValue: 0,
- },
- {
- label: "背景",
- prop: "",
- type: "divider",
- },
- {
- label: "背景",
- prop: "legend.backgroundColor",
- type: "backgroundSelect",
- fieldProps: {
- filterOptions: ["image"],
- },
- defaultValue: {
- type: "color",
- color: "#fff",
- },
- format: (formatModel, value) => {
- formatModel.value["legend.backgroundColor"] = value?.type === 'color' ? value.color : 'none';
- },
- valueToForm: (value) => {
- return !value || value === 'none'
- ? {
- type: 'none'
- }
- : {
- type: "color",
- color: value.color,
- };
- },
- },
- {
- label: "阴影",
- prop: "legend.shadowBlur",
- type: "radioGroup",
- fieldProps: {
- options: [
- { label: "开启", value: true },
- { label: "关闭", value: false },
- ],
- },
- defaultValue: false,
- format: (formatModel, value) => {
- formatModel.value["legend.shadowBlur"] = value ? 10 : 0;
- formatModel.value["legend.shadowColor"] = "#000";
- },
- valueToForm: (value) => {
- return value ? true : false;
- },
- },
- ]
- : [];
- },
- },
- ],
- },
- /* 系列 */
- series: {
- label: "系列",
- prop: "series",
- type: "group",
- children: [
- {
- label: "配色",
- prop: "color",
- type: "colorScheme",
- defaultValue: colorPreset[0].color,
- },
- ],
- },
- /* X轴 */
- xAxis: {
- label: "X 轴",
- prop: "xAxis",
- type: "group",
- children: [
- {
- label: "类型",
- prop: "xAxis.type",
- type: "select",
- fieldProps: {
- options: [
- { label: "类目坐标轴", value: "category" },
- { label: "数值坐标轴", value: "value" },
- { label: "时间坐标轴", value: "time" },
- ],
- },
- defaultValue: "category",
- },
- {
- label: " ",
- prop: "xAxis.showName",
- type: "checkboxGroup",
- fieldProps: {
- options: [{ label: "显示轴标题", value: true }],
- },
- defaultValue: [true],
- format: (formatModel, value) => {
- formatModel.value["xAxis.showName"] = value?.length ? true : false;
- },
- valueToForm: (value) => {
- return value ? [true] : [];
- },
- },
- {
- label: "",
- prop: "",
- type: "dependency",
- name: ["xAxis.showName"],
- children: (model) => {
- return model["xAxis.showName"].length
- ? [
- {
- label: "标题内容",
- prop: "xAxis.name",
- type: "input",
- defaultValue: "X 轴标题",
- format: (formatModel, value) => {
- if (formatModel.value["xAxis.showName"]) {
- formatModel.value["xAxis.name"] = value;
- formatModel.value["grid.bottom"] = 40;
- } else {
- formatModel.value["xAxis.name"] = "";
- formatModel.value["grid.bottom"] = 20;
- }
- },
- },
- {
- label: "标题位置",
- prop: "xAxis.nameLocation",
- type: "position",
- defaultValue: "center",
- format: (formatModel, value: "left" | "center" | "right") => {
- const p = {
- left: "start",
- center: "middle",
- right: "end",
- };
- formatModel.value["xAxis.nameLocation"] = value
- ? p[value]
- : "middle";
- },
- valueToForm: (value) => {
- const p = {
- start: "left",
- middle: "center",
- end: "right",
- };
- return p[value];
- },
- },
- {
- label: "标题样式",
- prop: "xAxis.nameTextStyle",
- type: "fontStyle",
- defaultValue: {
- color: "#000000ff",
- size: 12,
- bold: false,
- italic: false,
- },
- format: (formatModel, value) => {
- formatModel.value["xAxis.nameTextStyle"] = {
- color: value.color,
- fontSize: value.size,
- fontWeight: value.bold ? "bold" : "normal",
- fontStyle: value.italic ? "italic" : "normal",
- };
- },
- valueToForm: (_, model) => {
- return {
- color: get(model, 'xAxis.nameTextStyle.color', '#000000ff'),
- size: get(model, 'xAxis.nameTextStyle.fontSize', 12),
- bold: get(model, 'xAxis.nameTextStyle.fontWeight') === 'bold',
- italic: get(model, 'xAxis.nameTextStyle.fontStyle') === 'italic',
- }
- }
- },
- ]
- : [];
- },
- },
- {
- label: "轴线",
- prop: "",
- type: "divider",
- },
- {
- label: "线宽",
- prop: "xAxis.axisLine.width",
- type: "inputNumber",
- fieldProps: {
- addonAfter: "px",
- },
- defaultValue: 1,
- },
- {
- label: "颜色",
- prop: "xAxis.axisLine.color",
- type: "colorSelect",
- defaultValue: "#ccc",
- },
- {
- label: "刻度",
- prop: "",
- type: "divider",
- },
- {
- label: " ",
- prop: "xAxis.axisTick.show",
- type: "checkboxGroup",
- fieldProps: {
- options: [{ label: "显示刻度", value: true }],
- },
- defaultValue: [true],
- format: (formatModel, value) => {
- formatModel.value["xAxis.axisTick.show"] = value?.length
- ? true
- : false;
- },
- valueToForm: (value) => {
- return value ? [true] : [];
- },
- },
- {
- label: "",
- prop: "",
- type: "dependency",
- name: ["xAxis.axisTick.show"],
- children: (model) => {
- return model["xAxis.axisTick.show"].length
- ? [
- {
- label: "刻度宽度",
- prop: "xAxis.axisTick.lineStyle.width",
- type: "inputNumber",
- fieldProps: {
- addonAfter: "px",
- },
- defaultValue: 5,
- },
- {
- label: "刻度颜色",
- prop: "xAxis.axisTick.lineStyle.color",
- type: "colorSelect",
- defaultValue: "#ccc",
- },
- ]
- : [];
- },
- },
- {
- label: "标签",
- prop: "",
- type: "divider",
- },
- {
- label: " ",
- prop: "xAxis.axisLabel.show",
- type: "checkboxGroup",
- fieldProps: {
- options: [{ label: "显示标签", value: true }],
- },
- defaultValue: [true],
- format: (formatModel, value) => {
- formatModel.value["xAxis.axisLabel.show"] = value?.length
- ? true
- : false;
- },
- valueToForm: (value) => {
- return value ? [true] : [];
- },
- },
- {
- label: "",
- prop: "",
- type: "dependency",
- name: ["xAxis.axisLabel.show"],
- children: (model) => {
- return model["xAxis.axisLabel.show"].length
- ? [
- {
- label: "样式",
- prop: "xAxis.axisLabel",
- type: "fontStyle",
- defaultValue: {
- color: "#000000ff",
- size: 12,
- bold: false,
- italic: false,
- },
- format: (formatModel, value) => {
- formatModel.value["xAxis.axisLabel.color"] = value?.color;
- formatModel.value["xAxis.axisLabel.fontSize"] = value.size;
- formatModel.value["xAxis.axisLabel.fontWeight"] = value.bold
- ? "bold"
- : "normal";
- formatModel.value["xAxis.axisLabel.fontStyle"] =
- value.italic ? "italic" : "normal";
- },
- valueToForm: (_, model) => {
- return {
- color: get(model, 'xAxis.axisLabel.color', '#000000ff'),
- size: get(model, 'xAxis.axisLabel.fontSize', 12),
- bold: get(model, 'xAxis.axisLabel.fontWeight') === 'bold',
- italic: get(model, 'xAxis.axisLabel.fontStyle') === 'italic',
- }
- }
- },
- ]
- : [];
- },
- },
- ],
- },
- /* Y 轴 */
- yAxis: {
- label: "Y 轴",
- prop: "yAxis",
- type: "group",
- children: [
- {
- label: " ",
- prop: "yAxis.show",
- type: "checkboxGroup",
- fieldProps: {
- options: [{ label: "显示轴标题", value: true }],
- },
- defaultValue: [],
- format: (formatModel, value) => {
- formatModel.value["yAxis.show"] = value?.length ? true : false;
- },
- valueToForm: (value) => {
- return value ? [true] : [];
- },
- },
- {
- label: "",
- prop: "",
- type: "dependency",
- name: ["yAxis.show"],
- children: (model) => {
- return model["yAxis.show"].length
- ? [
- {
- label: "标题内容",
- prop: "yAxis.name",
- type: "input",
- defaultValue: "Y 轴标题",
- format: (formatModel, value) => {
- if (formatModel.value["yAxis.show"]) {
- formatModel.value["yAxis.name"] = value;
- formatModel.value["grid.left"] = 40;
- } else {
- formatModel.value["yAxis.name"] = "";
- formatModel.value["grid.left"] = 20;
- }
- },
- },
- {
- label: "标题位置",
- prop: "yAxis.nameLocation",
- type: "position",
- defaultValue: "center",
- format: (formatModel, value: "left" | "center" | "right") => {
- const p = {
- left: "start",
- center: "middle",
- right: "end",
- };
- formatModel.value["yAxis.nameLocation"] = value
- ? p[value]
- : "middle";
- },
- valueToForm: (value) => {
- const p = {
- start: "left",
- middle: "center",
- end: "right",
- };
- return p[value];
- },
- },
- {
- label: "标题样式",
- prop: "yAxis.nameTextStyle",
- type: "fontStyle",
- defaultValue: {
- color: "#000000ff",
- size: 12,
- bold: false,
- italic: false,
- },
- format: (formatModel, value) => {
- formatModel.value["yAxis.nameTextStyle"] = {
- color: value.color,
- fontSize: value.size,
- fontWeight: value.bold ? "bold" : "normal",
- fontStyle: value.italic ? "italic" : "normal",
- };
- },
- valueToForm: (_, model) => {
- return {
- color: get(model, 'yAxis.nameTextStyle.color', '#000000ff'),
- size: get(model, 'yAxis.nameTextStyle.fontSize', 12),
- bold: get(model, 'yAxis.nameTextStyle.fontWeight') === 'bold',
- italic: get(model, 'yAxis.nameTextStyle.fontStyle') === 'italic',
- }
- }
- },
- ]
- : [];
- },
- },
- {
- label: "轴线",
- prop: "",
- type: "divider",
- },
- {
- label: "线宽",
- prop: "yAxis.axisLine.width",
- type: "inputNumber",
- fieldProps: {
- addonAfter: "px",
- },
- defaultValue: 1,
- },
- {
- label: "颜色",
- prop: "yAxis.axisLine.color",
- type: "colorSelect",
- defaultValue: "#ccc",
- },
- {
- label: "刻度",
- prop: "",
- type: "divider",
- },
- {
- label: " ",
- prop: "yAxis.axisTick.show",
- type: "checkboxGroup",
- fieldProps: {
- options: [{ label: "显示刻度", value: true }],
- },
- defaultValue: [true],
- format: (formatModel, value) => {
- formatModel.value["yAxis.axisTick.show"] = value?.length
- ? true
- : false;
- },
- valueToForm: (value) => {
- return value ? [true] : [];
- }
- },
- {
- label: "",
- prop: "",
- type: "dependency",
- name: ["yAxis.axisTick.show"],
- children: (model) => {
- return model["yAxis.axisTick.show"].length
- ? [
- {
- label: "刻度长度",
- prop: "yAxis.axisTick.lineStyle.width",
- type: "inputNumber",
- fieldProps: {
- addonAfter: "px",
- },
- defaultValue: 5,
- },
- {
- label: "刻度颜色",
- prop: "yAxis.axisTick.lineStyle.color",
- type: "colorSelect",
- defaultValue: "#ccc",
- },
- ]
- : [];
- },
- },
- {
- label: "标签",
- prop: "",
- type: "divider",
- },
- {
- label: " ",
- prop: "yAxis.axisLabel.show",
- type: "checkboxGroup",
- fieldProps: {
- options: [{ label: "显示标签", value: true }],
- },
- defaultValue: [true],
- format: (formatModel, value) => {
- formatModel.value["yAxis.axisLabel.show"] = value?.length
- ? true
- : false;
- },
- valueToForm: (value) => {
- return value ? [true] : [];
- }
- },
- {
- label: "",
- prop: "",
- type: "dependency",
- name: ["yAxis.axisLabel.show"],
- children: (model) => {
- return model["yAxis.axisLabel.show"].length
- ? [
- {
- label: "样式",
- prop: "yAxis.axisLabel",
- type: "fontStyle",
- defaultValue: {
- color: "#000000ff",
- size: 12,
- bold: false,
- italic: false,
- },
- format: (formatModel, value) => {
- formatModel.value["yAxis.axisLabel.color"] = value?.color;
- formatModel.value["yAxis.axisLabel.fontSize"] = value.size;
- formatModel.value["yAxis.axisLabel.fontWeight"] = value.bold
- ? "bold"
- : "normal";
- formatModel.value["yAxis.axisLabel.fontStyle"] =
- value.italic ? "italic" : "normal";
- },
- valueToForm: (_, model) => {
- return {
- color: get(model, 'yAxis.axisLabel.color', '#000000ff'),
- size: get(model, 'yAxis.axisLabel.fontSize', 12),
- bold: get(model, 'yAxis.axisLabel.fontWeight') === 'bold',
- italic: get(model, 'yAxis.axisLabel.fontStyle') === 'italic',
- }
- }
- },
- ]
- : [];
- },
- },
- ],
- },
- /* 提示 */
- tooltip: {
- label: "提示",
- prop: "tooltip",
- type: "group",
- children: [
- {
- label: " ",
- prop: "tooltip.show",
- type: "checkboxGroup",
- fieldProps: {
- options: [{ label: "提示可见", value: true }],
- },
- defaultValue: [true],
- format: (formatModel, value) => {
- formatModel.value["tooltip.show"] = value?.length ? true : false;
- },
- valueToForm: (value) => {
- return value ? [true] : [];
- }
- },
- {
- label: "",
- prop: "",
- type: "dependency",
- name: ["tooltip.show"],
- children: (model) => {
- return model["tooltip.show"].length
- ? [
- {
- label: "文本",
- prop: "tooltip.formatter",
- type: "checkboxGroup",
- fieldProps: {
- options: [
- { label: "分类名", value: "b" },
- { label: "系列名", value: "a" },
- { label: "数值", value: "c" },
- ],
- },
- defaultValue: ["b"],
- format: (formatModel, list) => {
- formatModel.value["tooltip.formatter"] = list.map((item) => `{${item}}`).join(" ");
- },
- valueToForm: (_, model) => {
- return get(model, 'tooltip.formatter')?.replace(/\{|\}/g, "")?.split(" ");
- }
- },
- {
- label: "格式化",
- prop: "tooltip.valueFormatter",
- type: "input",
- tip: "支持字符串模板和回调函数",
- defaultValue: "(value, dataIndex) => value",
- },
- {
- label: "样式",
- prop: "tooltip.textStyle",
- type: "fontStyle",
- defaultValue: {
- color: "#000000ff",
- size: 12,
- bold: false,
- italic: false,
- },
- format: (formatModel, value) => {
- formatModel.value["tooltip.textStyle"] = {
- color: value.color,
- fontSize: value.size,
- fontWeight: value.bold ? "bold" : "normal",
- fontStyle: value.italic ? "italic" : "normal",
- };
- },
- valueToForm: (_, model) => {
- return {
- color: get(model, 'tooltip.textStyle.color', '#000000ff'),
- size: get(model, 'tooltip.textStyle.fontSize', 12),
- bold: get(model, 'tooltip.textStyle.fontWeight') === 'bold',
- italic: get(model, 'tooltip.textStyle.fontStyle') === 'italic',
- }
- }
- },
- {
- label: "边框",
- prop: "",
- type: "divider",
- },
- {
- label: "线宽",
- prop: "tooltip.borderWidth",
- type: "inputNumber",
- fieldProps: {
- addonAfter: "px",
- },
- defaultValue: 1,
- },
- {
- label: "颜色",
- prop: "tooltip.borderColor",
- type: "colorSelect",
- defaultValue: "#ccc",
- },
- {
- label: "背景",
- prop: "",
- type: "divider",
- },
- {
- label: "填充",
- prop: "tooltip.backgroundColor",
- type: "backgroundSelect",
- fieldProps: {
- filterOptions: ["image"],
- },
- defaultValue: {
- type: "color",
- color: "#fff",
- },
- format: (formatModel, value) => {
- formatModel.value["tooltip.backgroundColor"] = value?.type === 'color' ? value.color : 'none';
- },
- valueToForm: (value) => {
- return !value || value === 'none'
- ? {
- type: 'none'
- }
- : {
- type: "color",
- color: value.color,
- };
- },
- },
- {
- label: "阴影",
- prop: "tooltip.extraCssText",
- type: "radioGroup",
- fieldProps: {
- options: [
- { label: "开启", value: true },
- { label: "关闭", value: false },
- ],
- },
- defaultValue: false,
- format: (formatModel, value) => {
- formatModel.value["tooltip.extraCssText"] = value
- ? "box-shadow: 0 0 3px rgba(0, 0, 0, 0.3);"
- : "";
- },
- valueToForm: (_, model) => {
- return get(model, 'tooltip.extraCssText') ? true : false;
- }
- },
- ]
- : [];
- },
- },
- ],
- },
- /* 标签 */
- label: {
- label: "标签",
- prop: "label",
- type: "group",
- children: [
- {
- label: " ",
- prop: "label.show",
- type: "checkboxGroup",
- fieldProps: {
- options: [{ label: "标签可见", value: true }],
- },
- defaultValue: [],
- format: (formatModel, value) => {
- formatModel.value["label.show"] = value?.length ? true : false;
- },
- valueToForm: (value) => {
- return value ? [true] : [];
- }
- },
- {
- label: "",
- prop: "",
- type: "dependency",
- name: ["label.show"],
- children: (model) => {
- return model["label.show"].length
- ? [
- {
- label: "文本",
- prop: "label.formatter",
- type: "checkboxGroup",
- fieldProps: {
- options: [
- { label: "分类名", value: "b" },
- { label: "系列名", value: "a" },
- { label: "数值", value: "c" },
- // { label: "百分比", value: "percent" },
- ],
- },
- defaultValue: ["a"],
- format: (formatModel, value) => {
- formatModel.value["label.formatter"] = `{${value}}`;
- },
- valueToForm: (_, model) => {
- return get(model, 'label.formatter')?.replace(/\{|\}/g, "")?.split(" ");
- }
- },
- {
- label: "样式",
- prop: "label.fontStyle",
- type: "fontStyle",
- defaultValue: {
- color: "#000000ff",
- size: 12,
- bold: false,
- italic: false,
- },
- format: (formatModel, value) => {
- formatModel.value["label.color"] = value?.color;
- formatModel.value["label.fontSize"] = value.size;
- formatModel.value["label.fontWeight"] = value.bold
- ? "bold"
- : "normal";
- formatModel.value["label.fontStyle"] = value.italic
- ? "italic"
- : "normal";
- },
- valueToForm: (_, model) => {
- return {
- color: get(model, 'label.color', '#000000ff'),
- size: get(model, 'label.fontSize', 12),
- bold: get(model, 'label.fontWeight') === 'bold',
- italic: get(model, 'label.fontStyle') === 'italic',
- }
- }
- },
- {
- label: "布局",
- prop: "",
- type: "divider",
- },
- {
- label: "位置",
- prop: "label.position",
- type: "radioGroup",
- fieldProps: {
- options: [
- { label: "顶部", value: "top" },
- { label: "左侧", value: "left" },
- { label: "右侧", value: "right" },
- { label: "底部", value: "bottom" },
- { label: "内部", value: "inside" },
- { label: "内部左侧", value: "insideLeft" },
- { label: "内部右侧", value: "insideRight" },
- { label: "内部顶部", value: "insideTop" },
- { label: "内部底部", value: "insideBottom" },
- ],
- },
- defaultValue: "top",
- },
- {
- label: "文本方向",
- prop: "label.rotate",
- type: "radioGroup",
- fieldProps: {
- options: [
- { label: "水平", value: "horizontal" },
- { label: "垂直", value: "vertical" },
- ],
- },
- defaultValue: "horizontal",
- format: (formatModel, value) => {
- formatModel.value["label.rotate"] =
- value === "horizontal" ? 0 : 90;
- },
- valueToForm: (value) => {
- return value === 0 ? "horizontal" : "vertical";
- },
- },
- {
- label: "边框",
- prop: "",
- type: "divider",
- },
- {
- label: "线宽",
- prop: "label.borderWidth",
- type: "inputNumber",
- fieldProps: {
- addonAfter: "px",
- },
- defaultValue: 0,
- },
- {
- label: "颜色",
- prop: "label.borderColor",
- type: "colorSelect",
- defaultValue: "#ccc",
- },
- {
- label: "圆角",
- prop: "label.borderRadius",
- type: "inputNumber",
- fieldProps: {
- addonAfter: "px",
- },
- defaultValue: 0,
- },
- ]
- : [];
- },
- },
- ],
- },
- };
|