how to add data label to bubble chart in excel

前端 未结 2 1389
庸人自扰
庸人自扰 2021-01-24 18:23

Hi I want to add customize data label to my bubble chart. my code is below. at the moment data label refer to XValues. I would like my data label fill with bubble size. would u

2条回答
  •  猫巷女王i
    2021-01-24 18:42

    DataLabel.Text is a method for a Point, not the NewSeries

    This code:

    For r = 2 To Selection.Rows.Count
        With bubbleChart.Chart.SeriesCollection.NewSeries
            [...]
            .DataLabel.Text = "txt"
        End With 
    Next
    

    ...attempts to label the series, and fails.

    Recognizing this code as being from another famous example of "multi-series Bubble Charts", it is a logical assumption that we only need to handle 1 data point per series, which makes the following code the solution:

    For r = 2 To Selection.Rows.Count
        With bubbleChart.Chart.SeriesCollection.NewSeries
            [...]
            .Points(1).HasDataLabel = True
            .Points(1).DataLabel.Text = "txt"
        End With 
    Next
    

提交回复
热议问题