|
|
|
|
@ -237,15 +237,18 @@ export default { |
|
|
|
|
symbol: 'roundRect', |
|
|
|
|
itemStyle: { |
|
|
|
|
color: '#284c89', |
|
|
|
|
borderWidth: 2, |
|
|
|
|
borderColor: '#fff', |
|
|
|
|
borderRadius: 4, // 圆角半径,值越大圆角越明显 |
|
|
|
|
}, |
|
|
|
|
// 动态计算节点大小:宽度=最长文本宽度,高度=行数*行高+内边距 |
|
|
|
|
symbolSize: params => { |
|
|
|
|
symbolSize: (val, params) => { |
|
|
|
|
// 容错:params为空/无name时给默认值 |
|
|
|
|
const nodeName = params?.name || '未知节点'; |
|
|
|
|
const childCount = params?.children?.length || 0; |
|
|
|
|
const childText = `${childCount}个子件`; |
|
|
|
|
// 计算文本宽度 |
|
|
|
|
const textWidth = Math.max(nodeName.length * 12, childText.length * 12) + 20; |
|
|
|
|
const textWidth = Math.max(nodeName.length * 12, childText.length * 12) + 30; |
|
|
|
|
return [Math.max(textWidth, 100), 60]; // 高度设为60px(适配两行文本) |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
@ -258,9 +261,11 @@ export default { |
|
|
|
|
lineHeight: 20, |
|
|
|
|
color: '#fff', |
|
|
|
|
formatter: params => { |
|
|
|
|
const childText =params.data.quota>=0?`${params.data.quota}个`:'' |
|
|
|
|
const childText = params.data.quota >= 0 ? `${params.data.quota}个` : ''; |
|
|
|
|
// 去掉模板字符串缩进,用\n换行,避免多余空白 |
|
|
|
|
return `${params.name}${childText ? '\n' + childText : ''}`; |
|
|
|
|
return `${params.data.partCode}\n${params.name}${ |
|
|
|
|
childText ? '\n' + childText : '' |
|
|
|
|
}`; |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
|