+ Reply to Thread
Results 1 to 6 of 6

Leader / Leading Lines in Bubble Chart

  1. #1
    Registered User
    Join Date
    01-23-2013
    Location
    New York, NY
    MS-Off Ver
    Excel 2010
    Posts
    18

    Leader / Leading Lines in Bubble Chart

    Hi,

    I have bubble charts (up to 30 with 35 points each) that I need to format with leader lines to each bubble. As you can imagine, this becomes pretty tedious...

    I already have some VBA to attach the data points, but was wondering if anyone knew how to tell excel to draw a line from the bubble to the data point (the data points are all associated with the bubbles).

    I don't know where to start, any advice is appreciated!

    Thanks

    Edit: this is for excel 2010, I think excel 2013 has this capability, but my office doesn't have that yet. I'm also not allowed to install 3rd party software, unfortunately.

  2. #2
    Registered User
    Join Date
    01-23-2013
    Location
    New York, NY
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Leader / Leading Lines in Bubble Chart

    I know the basic way I would accomplish this, but am VBA limited so the coding is difficult for me to wrap my head around:
    1. activate the chart
    2. cycle through all data points on the chart in a loop (for or if)
    2a. Get the position of point (x) -> save this as a value (PointPosition)
    2b. Get the position of points.datalabel(x) vi - save this as a value (LabelPosition)
    2c. Activecharts.shapes.addconnector(msoConnectorStraight, PointPosition,LabelPosition)
    3. Repeat as necessary through points.

  3. #3
    Registered User
    Join Date
    01-23-2013
    Location
    New York, NY
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Leader / Leading Lines in Bubble Chart

    Here is what I have so far...this works to do what I needed, attach leader lines from data labels to the center of the bubbles, but now I'm wondering if anyone has any ideas on how to have the lines be "beneath" the data labels so they don't go over the text. I tried filling the data labels with white but the lines are still on top of them...is there a way to layer the lines underneath, or force all the data labels on top??

    Sub AttachLeaderLines()
    '
    ' Attach Leader Lines Macro
    ' Andrew McLaughlin

    '
    Dim i As Integer
    Dim j As Integer
    Dim xCntPoint As Integer
    Dim PointTopDistance As Single
    Dim PointLeftDistance As Single
    Dim LabelTopDistance As Single
    Dim LabelLeftDistance As Single
    Dim LabelHeight As Single
    Dim LabelWidth As Single
    Dim BubbleWidth As Integer
    Dim BubbleHeight As Integer
    Dim PlotLeftDistance As Single
    Dim PlotTopDistance As Single
    Dim PlotHeight As Single
    Dim PlotWidth As Single
    Dim BubbleCenterLeft As Single
    Dim BubbleCenterTop As Single
    Dim LabelCenterLeft As Single
    Dim LabelCenterTop As Single


    i = 0

    ActiveSheet.ChartObjects("Chart 1").Activate

    PlotLeftDistance = ActiveChart.PlotArea.InsideLeft
    PlotTopDistance = ActiveChart.PlotArea.InsideTop
    PlotHeight = ActiveChart.PlotArea.InsideHeight
    PlotWidth = ActiveChart.PlotArea.InsideWidth

    xCntPoint = 1
    j = ActiveChart.SeriesCollection(1).Points.Count

    For i = 1 To j

    PointTopDistance = ActiveChart.SeriesCollection(1).Points(xCntPoint).Top
    PointLeftDistance = ActiveChart.SeriesCollection(1).Points(xCntPoint).Left
    BubbleWidth = ActiveChart.SeriesCollection(1).Points(xCntPoint).Width
    BubbleHeight = ActiveChart.SeriesCollection(1).Points(xCntPoint).Height
    BubbleCenterLeft = PointLeftDistance + BubbleWidth / 2
    BubbleCenterTop = PointTopDistance + BubbleHeight / 2
    LabelTopDistance = ActiveChart.SeriesCollection(1).Points(xCntPoint).DataLabel.Top
    LabelLeftDistance = ActiveChart.SeriesCollection(1).Points(xCntPoint).DataLabel.Left
    LabelHeight = ActiveChart.SeriesCollection(1).Points(xCntPoint).DataLabel.Height
    LabelWidth = ActiveChart.SeriesCollection(1).Points(xCntPoint).DataLabel.Width
    LabelCenterLeft = LabelLeftDistance + LabelWidth / 2
    LabelCenterTop = LabelTopDistance + LabelHeight / 2

    ActiveChart.Shapes.AddConnector(msoConnectorStraight, BubbleCenterLeft, _
    BubbleCenterTop, LabelCenterLeft, LabelCenterTop).Select

    xCntPoint = xCntPoint + 1

    Next i



    End Sub

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,430

    Re: Leader / Leading Lines in Bubble Chart

    one possible approach

    http://andypope.info/ngs/ng14.htm
    Cheers
    Andy
    www.andypope.info

  5. #5
    Registered User
    Join Date
    01-23-2013
    Location
    New York, NY
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Leader / Leading Lines in Bubble Chart

    Thanks, but that approach is pretty limited (can only do 90 degree angles) and very manual. Appreciate the input though.

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,430

    Re: Leader / Leading Lines in Bubble Chart

    You are limited with a bubble chart. You can not create a combination chart when using bubble so using alternative chart type, such as xy-scatter, is not possible.

    Error bars give you horizontal/vertical lines.

    The only other builtin line you have available is a trend line. But that is not practical in this case.

    If you have xl2013 introduces builtin leader lines.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 06-19-2012, 07:48 AM
  2. Leader lines
    By hermithead in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 12-01-2009, 05:26 AM
  3. Edit bubble behind another bubble in bubble chart (2007)
    By JayUSA in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 07-14-2009, 03:10 PM
  4. Creating X & Y Mean Lines on Bubble Chart
    By Chris Turnbull in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 01-17-2006, 04:10 PM
  5. Leader lines with pie chart
    By sumit_sethi in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 05-24-2005, 12:51 AM
  6. [SOLVED] Leader Lines Connecting Chart to Box
    By TOMB in forum Excel General
    Replies: 1
    Last Post: 05-07-2005, 02:07 PM
  7. [SOLVED] Leader Lines Connecting Chart to Box
    By TOMB in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 05-07-2005, 01:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1