Commit 12b90ac5 authored by 水玉婷's avatar 水玉婷
Browse files

feat:修改饼图图例样式

parent f3e50e14
...@@ -233,21 +233,20 @@ const createPieChartOption = (pieData: any[]) => { ...@@ -233,21 +233,20 @@ const createPieChartOption = (pieData: any[]) => {
...getBaseChartConfig(), ...getBaseChartConfig(),
tooltip: getBaseTooltipConfig(), tooltip: getBaseTooltipConfig(),
legend: { legend: {
orient: 'horizontal', orient: 'horizontal' as const,
top: 0, left: 'center' as const,
left: 'center', top: '0' as const,
type: 'scroll', padding: [10, 20, 0, 20], // 调整padding,确保顶部有足够空间
itemGap: 15,
type: 'scroll' as const,
textStyle: { textStyle: {
fontSize: 12 fontSize: 12
}, },
selected: selectedData, pageTextStyle: {
// 数据项多时调整图例位置 fontSize: 10
...(isManyItems && { },
orient: 'vertical', pageIconSize: 12,
right: 5, pageButtonItemGap: 5
top: 'middle',
height: '80%'
})
}, },
series: [{ series: [{
name: props.title, name: props.title,
...@@ -299,8 +298,8 @@ const createPieChartOption = (pieData: any[]) => { ...@@ -299,8 +298,8 @@ const createPieChartOption = (pieData: any[]) => {
color: colors, color: colors,
selectedMode: 'single', selectedMode: 'single',
selectedOffset: 5, // 减小选中偏移量,避免庙边效果 selectedOffset: 5, // 减小选中偏移量,避免庙边效果
// 使用响应式布局 // 使用响应式布局,为上方图例留出空间
top: '10%', top: isManyItems ? '15%' : '10%',
bottom: '5%', bottom: '5%',
left: responsiveLayout.left, left: responsiveLayout.left,
right: responsiveLayout.right right: responsiveLayout.right
...@@ -369,12 +368,14 @@ const getResponsiveLayout = (isManyItems: boolean) => { ...@@ -369,12 +368,14 @@ const getResponsiveLayout = (isManyItems: boolean) => {
if (screenWidth < 768) { // 小屏幕 if (screenWidth < 768) { // 小屏幕
return { return {
top: isManyItems ? '15%' : '10%',
left: '5%', left: '5%',
right: '5%', right: '5%',
radius: isManyItems ? ['25%', '50%'] : ['35%', '60%'] radius: isManyItems ? ['25%', '50%'] : ['35%', '60%']
}; };
} else if (screenWidth < 1200) { // 中等屏幕 } else if (screenWidth < 1200) { // 中等屏幕
return { return {
top: isManyItems ? '15%' : '10%',
left: '25%', left: '25%',
right: '25%', right: '25%',
radius: isManyItems ? ['30%', '55%'] : ['40%', '65%'] radius: isManyItems ? ['30%', '55%'] : ['40%', '65%']
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment