From 21258fc1d47772cab2c3e1830ea6e01f3e8bd10d Mon Sep 17 00:00:00 2001 From: "hong.yang" Date: Mon, 6 Nov 2023 17:59:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E9=A5=BC=E5=9B=BE?= =?UTF-8?q?=E5=92=8C=E7=8E=AF=E5=9B=BE=E7=9A=84=E9=85=8D=E7=BD=AE=EF=BC=8C?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=99=BE=E5=88=86=E6=AF=94=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../packages/G2Plots/饼图/基础环图.js | 43 ++++++++++++++++--- .../packages/G2Plots/饼图/基础饼图.js | 3 +- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/data-room-ui/packages/G2Plots/饼图/基础环图.js b/data-room-ui/packages/G2Plots/饼图/基础环图.js index 6de6ee3e..8a6993e2 100644 --- a/data-room-ui/packages/G2Plots/饼图/基础环图.js +++ b/data-room-ui/packages/G2Plots/饼图/基础环图.js @@ -46,19 +46,32 @@ const setting = [ // 设置组件类型 type: 'select', // 字段 - field: 'label_content', + field: 'label_contentList', // 对应options中的字段 - optionField: 'label.content', - value: '{value}', + optionField: 'label.contentList', + value: ['{value}'], tabName: 'custom', + multiple: true, options: [ { label: '维度', value: '{name}' }, - { label: '指标', value: '{value}' } + { label: '指标', value: '{value}' }, + { label: '百分比', value: '{percentage}' }, ], step: 0.1, max: 1, groupName: 'graph' }, + { + label: '旋转内部标签', + type: 'switch', // 设置组件类型 + field: 'labelAutoRotate', // 字段 + optionField: 'label.autoRotate', // 对应options中的字段 + value: false, + active: true, + inactive: false, + tabName: 'custom', + groupName: 'graph' + }, { label: '标签位置', // 设置组件类型 @@ -365,7 +378,25 @@ const data = [ const optionHandler = 'option.legend = option.legendEnable ? {position: setting.find(settingItem=>settingItem.field === \'legendPosition\').value} : false;' + '\n if (option.legendEnable) {\n' + ' option.legend.itemName = option.legendItemName\n' + - ' }' + ' }' + + `if (option.label.contentList && option.label.contentList.length > 0) { + let content = '' + if (option.label.contentList.length === 1) { + content = option.label.contentList[0] + } else { + // 多行文本,加换行符,但是最后一行不加 + option.label.contentList.forEach((item, index) => { + if (index === option.label.contentList.length - 1) { + content += item + } else { + content += item + '\\n' + } + }) + } + option.label.content = content +}` + + // 数据处理脚本 const dataHandler = '' @@ -394,6 +425,7 @@ const option = { color: ['#6b74e4', '#4391f4', '#38bbe5', '#69d6fd', '#36c6a0'], label: { type: 'inner', + autoRotate: false, labelLine: { style: { stroke: '#5B8FF9', @@ -401,6 +433,7 @@ const option = { lineWidth: 1 } }, + contentList: [], content: '{value}', style: { fill: '#ffffff', diff --git a/data-room-ui/packages/G2Plots/饼图/基础饼图.js b/data-room-ui/packages/G2Plots/饼图/基础饼图.js index 7acf3189..6c995819 100644 --- a/data-room-ui/packages/G2Plots/饼图/基础饼图.js +++ b/data-room-ui/packages/G2Plots/饼图/基础饼图.js @@ -53,7 +53,8 @@ const setting = [ tabName: 'custom', options: [ { label: '维度', value: '{name}' }, - { label: '指标', value: '{value}' } + { label: '指标', value: '{value}' }, + { label: '百分比', value: '{percentage}' } ], step: 0.1, max: 1,