123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200 |
- 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",
- format: (formatModel, value) => {
- if(['left', 'right'].includes(value)) {
- formatModel.value["legend.orient"] = 'vertical';
- } else {
- formatModel.value["legend.orient"] = 'horizontal';
- }
- switch(value) {
- case 'bottom':
- formatModel.value["legend.top"] = 'auto';
- formatModel.value["legend.right"] = 'auto';
- formatModel.value["legend.bottom"] = 8;
- formatModel.value["legend.left"] = 'center';
- break;
- case 'left':
- formatModel.value["legend.bottom"] = 'auto';
- formatModel.value["legend.right"] = 'auto';
- formatModel.value["legend.left"] = 8;
- formatModel.value["legend.top"] = 'center';
- break;
- case 'right':
- formatModel.value["legend.bottom"] = 'auto';
- formatModel.value["legend.left"] = 'auto';
- formatModel.value["legend.right"] = 8;
- formatModel.value["legend.top"] = 'center';
- break;
- default:
- formatModel.value["legend.bottom"] = 'auto';
- formatModel.value["legend.right"] = 'auto';
- formatModel.value["legend.top"] = 32;
- formatModel.value["legend.left"] = 'center';
- }
- },
- valueToForm: (value, model) => {
- if(get(model, 'legend.orient') === 'vertical') {
- return value === 'top' ? 'top' : value === 'bottom' ? 'bottom' : 'left';
- }
- if(get(model, 'legend.bottom') === 8 && get(model, 'legend.left') === 'center') {
- return 'bottom';
- }
- return '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) => {
- if(value) {
- formatModel.value["legend.shadowBlur"] = 10;
- formatModel.value["legend.shadowColor"] = formatModel.value['legend.backgroundColor'] || '#000000ff';
- formatModel.value["legend.shadowOffsetX"] = 3;
- formatModel.value["legend.shadowOffsetY"] = 3;
- } else {
- formatModel.value["legend.shadowBlur"] = 0;
- formatModel.value["legend.shadowColor"] = "transparent";
- formatModel.value["legend.shadowOffsetX"] = 0;
- formatModel.value["legend.shadowOffsetY"] = 0;
- }
- },
- 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) => {
- if(value?.length) {
- formatModel.value["xAxis.showName"] = true;
- formatModel.value["xAxis.name"] = 'X轴标题';
- formatModel.value["xAxis.nameGap"] = 25;
- } else {
- formatModel.value["xAxis.showName"] = false;
- formatModel.value["xAxis.name"] = "";
- formatModel.value["xAxis.nameGap"] = 15;
- formatModel.value["xAxis.nameGap"] = 15;
- }
- },
- 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["xAxis.nameGap"] = 25;
- }
- },
- valueToForm: (value) => {
- return value || "X 轴标题";
- }
- },
- {
- 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: 'start' | 'middle' | 'end') => {
- const p = {
- start: "left",
- middle: "center",
- end: "right",
- };
- return p[value] || "center";
- },
- },
- {
- 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: (value) => {
- return {
- color: value?.color || '#000000ff',
- size: value?.fontSize || 12,
- bold: value?.fontWeight === 'bold' || false,
- italic: value?.fontStyle === 'italic' || false,
- }
- }
- },
- ]
- : [];
- },
- },
- {
- label: "轴线",
- prop: "",
- type: "divider",
- },
- {
- label: "线宽",
- prop: "xAxis.axisLine.lineStyle.width",
- type: "inputNumber",
- fieldProps: {
- addonAfter: "px",
- },
- defaultValue: 1,
- },
- {
- label: "颜色",
- prop: "xAxis.axisLine.lineStyle.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.showName",
- type: "checkboxGroup",
- fieldProps: {
- options: [{ label: "显示轴标题", value: true }],
- },
- defaultValue: [],
- format: (formatModel, value) => {
- if(value?.length) {
- formatModel.value["yAxis.showName"] = true;
- formatModel.value["yAxis.name"] = 'Y轴标题';
- formatModel.value["yAxis.nameGap"] = 25;
- } else {
- formatModel.value["yAxis.showName"] = false;
- formatModel.value["yAxis.name"] = "";
- formatModel.value["yAxis.nameGap"] = 15;
- }
- },
- valueToForm: (value) => {
- return value ? [true] : [];
- },
- },
- {
- label: "",
- prop: "",
- type: "dependency",
- name: ["yAxis.showName"],
- children: (model) => {
- return model["yAxis.showName"].length
- ? [
- {
- label: "标题内容",
- prop: "yAxis.name",
- type: "input",
- defaultValue: "Y 轴标题",
- format: (formatModel, value) => {
- if (formatModel.value["yAxis.showName"]) {
- formatModel.value["yAxis.name"] = value;
- formatModel.value["yAxis.nameGap"] = 25;
- } else {
- formatModel.value["yAxis.name"] = "";
- formatModel.value["yAxis.nameGap"] = 15;
- }
- },
- valueToForm: (value) => {
- return value || "Y 轴标题";
- }
- },
- {
- 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: "start" | "middle" | "end") => {
- const p = {
- start: "left",
- middle: "center",
- end: "right",
- };
- return p[value] || 'center ';
- },
- },
- {
- label: "标题样式",
- prop: "yAxis.nameTextStyle",
- type: "fontStyle",
- defaultValue: {
- color: "#FFFFFFFF",
- 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: (value) => {
- return {
- color: value?.color || '#000000ff',
- size: value?.fontSize || 12,
- bold: value?.fontWeight === 'bold' || false,
- italic: value?.fontStyle === 'italic' || false,
- }
- }
- },
- ]
- : [];
- },
- },
- {
- label: "轴线",
- prop: "",
- type: "divider",
- },
- {
- label: " ",
- prop: "yAxis.axisLine.show",
- type: "checkboxGroup",
- fieldProps: {
- options: [{ label: "显示轴线", value: true }],
- },
- defaultValue: [true],
- format: (formatModel, value) => {
- formatModel.value["yAxis.axisLine.show"] = value?.length
- ? true
- : false;
- },
- valueToForm: (value) => {
- return value ? [true] : [];
- }
- },
- {
- label: "",
- prop: "",
- type: "dependency",
- name: ["yAxis.axisLine.show"],
- children: (model) => {
- return model["yAxis.axisLine.show"].length
- ? [
- {
- label: "线宽",
- prop: "yAxis.axisLine.lineStyle.width",
- type: "inputNumber",
- fieldProps: {
- addonAfter: "px",
- },
- defaultValue: 1,
- },
- {
- label: "颜色",
- prop: "yAxis.axisLine.lineStyle.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',
- }
- }
- },
- {
- label: '旋转角度',
- prop: "yAxis.axisLabel.rotate",
- type: "inputNumber",
- fieldProps: {
- addonAfter: "°",
- min: -90,
- max: 90,
- step: 1
- },
- }
- ]
- : [];
- },
- },
- ],
- },
- /* 提示 */
- 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: any) => `{${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: "tooltip.borderRadius",
- type: "inputNumber",
- fieldProps: {
- addonAfter: "px",
- },
- defaultValue: 4,
- },
- {
- 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,
- };
- },
- },
- {
- 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,
- },
- ]
- : [];
- },
- },
- ],
- },
- };
|