gpt4 book ai didi

Excel/VBA : Adding a title to doughnut chart reduces size of doughnut

转载 作者:行者123 更新时间:2023-12-04 08:54:04 25 4
gpt4 key购买 nike

...但我希望我的 donut 是全尺寸的。因为我想将标题移动到 donut 的中心,所以我不需要上边距,它似乎是通过 Chart.HasTitle = True 添加的.我该如何解决这个问题?
示例代码

Sub createChart()
If ActiveSheet.ChartObjects.Count > 0 Then ActiveSheet.ChartObjects.Delete
Dim chrt As ChartObject
Dim dataRng As Range

Dim lft As Integer
lft = ActiveSheet.Range("D2").Left
Dim wdth As Integer
wdth = 500
Dim hgt As Integer
hgt = 300
Dim tp As Integer
tp = ActiveSheet.Range("D2").Top

Set chrt = ActiveSheet.ChartObjects.Add(Left:=lft, Width:=wdth, Height:=hgt, Top:=tp)
Dim i As Integer
For i = 1 To 10
ActiveSheet.Cells(i, 1).Value = "A" & i
With ActiveSheet.Cells(i, 2)
.Value = i / 55
.NumberFormat = "0.00%"
End With
Next i
Set dataRng = Range("A1:B10")

With chrt.Chart
.ChartType = xlDoughnut
.SetSourceData Source:=dataRng
' comment out from here
.HasTitle = True
With .ChartTitle
.Text = "Test"
.Top = hgt / 2
.Left = wdth / 2 - 20
End With
' to here
.HasLegend = False
End With
End Sub


最佳答案

添加行 .ChartTitle.IncludeInLayout = False.HasTitle = True 之后.
您可以阅读 documentation on the property有关它的作用的更多详细信息,但基本上您将其设置为

True if a chart title will occupy the chart layout space when a chart layout is being determined

关于Excel/VBA : Adding a title to doughnut chart reduces size of doughnut,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63933184/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com