Customizing Chart Elements > Programming ChartLabels > Batching ChartLabel Changes |
To improve efficiency, you can batch changes to a chart label. To do this, set the IsBatched property to True before changing any chart label properties, and set IsBatched to False once you have finished. This ensures that the chart will be updated only once, instead of after each property change.
Example
The following code defines a chart label that points to the chart's legend:
Dim label As Object
...
Set label = Chart2D1.ChartLabels.Add
With label
' Batch everything for even faster processing
.IsBatched = True
.Text = "That's the legend!"
' Set the method of the label attachment
.AttachMethod = oc2dAttachCoord
' Set the actual X-axis location for the label
.AttachCoord.X = Chart2D1.Legend.Location.Left
' Set the actual Y-axis location for the label
.AttachCoord.Y = Chart2D1.Legend.Location.Top
' Set the anchor point for the label
.Anchor = oc2dAnchorNorthWest
' Give it some room to draw a pointer line
.Offset = 20
.Border.Type = oc2dBorderShadow
.Border.Width = 4
' Draw the line between the label and the region
.IsConnected = True
.IsBatched = False
End With