+ Reply to Thread
Results 1 to 21 of 21

Bubble chart with 5 dimension + label

Hybrid View

  1. #1
    Registered User
    Join Date
    03-10-2010
    Location
    Italy
    MS-Off Ver
    Excel 2003
    Posts
    12

    Bubble chart with 5 dimension + label

    I would like to ask you if on a bubble chart we can manage 5 variables and a label field
    In particular, the variables are as follows:
    1. Name (Label)
    2. X (first variable)
    3. Y (second variable)
    4. Z (size)
    5. Z1 (shape code)
    6. Z2 (colour code)

    The variables X, Y, Z are managed by the Bubble chart but the other two variables:

    a) z1 should manage the shape of z;
    b) z2 should vary the colour of the indicator Z;

    I attach a dataset
    Attached Files Attached Files

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

    Re: Bubble chart with 5 dimension + label

    I have added 3 shapes to the worksheet and the colours are based on the schemecolor value.

    Sub XX()
        Dim chtTemp As Chart
        Dim shpTemp(3) As Shape
        Dim rngTable As Range
        Dim lngIndex As Long
        
        Set shpTemp(1) = ActiveSheet.Shapes("Rectangle 8")
        Set shpTemp(2) = ActiveSheet.Shapes("AutoShape 9")
        Set shpTemp(3) = ActiveSheet.Shapes("AutoShape 10")
        
        Set chtTemp = ActiveSheet.ChartObjects(1).Chart
        Set rngTable = Range("A2:F8")
        
        With chtTemp.SeriesCollection(1)
            .HasDataLabels = True
            For lngIndex = 1 To .Points.Count
                .Points(lngIndex).DataLabel.Text = rngTable.Cells(lngIndex, 1)
                With shpTemp(rngTable.Cells(lngIndex, 5))
                    .Fill.ForeColor.SchemeColor = rngTable.Cells(lngIndex, 6)
                    .Copy
                End With
                .Points(lngIndex).Paste
            Next
        End With
        
    End Sub
    Attached Files Attached Files
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    03-10-2010
    Location
    Italy
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Bubble chart with 5 dimension + label

    But if I manually change the field ‘s values z1 and z2 can I do the automatic update of the bubble plot?
    By
    Antonino

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

    Re: Bubble chart with 5 dimension + label

    Either run the macro again or run it via a worksheet change event.

  5. #5
    Registered User
    Join Date
    03-10-2010
    Location
    Italy
    MS-Off Ver
    Excel 2003
    Posts
    12

    Question Re: Bubble chart with 5 dimension + label

    Hi Andy,

    the macro works well on the data set that I previously sent to you; but I have still a problem:
    the information that the bubble plot manages come from a source that transmits them in real-time.

    I would like to ask you (because I do not not completely know VBA) if the update of the six variables on the bubble plot could take place automatically.

    I tried to play on the new dataset (A2: F51) my problem:
    1. Name (Label)  RANDBETWEEN [(1-100) & string]
    2. X (first variable) )  RANDBETWEEN (1-100)
    3. Y (second variable)  RANDBETWEEN (1-100)
    4. Z (size)  RANDBETWEEN (1-100)
    5. Z1 (shape code)  RANDBETWEEN (1-5)
    6. Z2 (color code) as follows:
    IF Shape = “square” =1 associed Color1 = red;
    IF Shape = “triangle” =2 associed Color2 = blue;
    IF Shape = “star” =3 associed Color3 = green;
    IF Shape = “cilinder” =4 associed Color4 = yellows;
    IF Shape = “oval” =5 associed Color5 = purple;

    I hope in your help

    bye-bye


    Antonino

    P.S.: I would like to ask you a curiosity: but the color of the shapes can be associated with the range of variation of the variable color (z2) according to a color that goes from red to blue depending on its range of variation of z2?
    If the answer is yes on which part of the code should I intervene?
    Attached Files Attached Files

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

    Re: Bubble chart with 5 dimension + label

    See attached.

    I have added a table of colours to the sheet that will be used by the code.

    I have not added event code as you are using Randbetween which will cause the macro to run many times.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    03-10-2010
    Location
    Italy
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Bubble chart with 5 dimension + label

    Hi Andy,
    I did a test with 5 cases, but it seemed that the bubble plot does not do the update of the field label, shape and colors.
    what can I do?
    bye-bye
    Antonino

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

    Re: Bubble chart with 5 dimension + label

    Did you manually run the macro?

    If you right click sheet tab and press View Code. Paste the following

    Private Sub Worksheet_Change(ByVal Target As Range)
    
        If Not Intersect(Range("A2:F51"), Target) Is Nothing Then
            XX
        End If
    
    End Sub
    If you then edit one of the cells the chart should refresh.
    Last edited by Andy Pope; 10-28-2010 at 06:53 AM.

  9. #9
    Registered User
    Join Date
    03-10-2010
    Location
    Italy
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Bubble chart with 5 dimension + label

    I inserted the new code on the sheet.
    I made a new test range reduced (A2: F6), but there is the problem of update of the fields.
    bye-bye
    A.

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

    Re: Bubble chart with 5 dimension + label

    So what exactly happens when you copy say F2 to F3?

  11. #11
    Registered User
    Join Date
    03-10-2010
    Location
    Italy
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Bubble chart with 5 dimension + label

    1) F2 the cursor goes into the cell
    2) F3 see attached image

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

    Re: Bubble chart with 5 dimension + label


  13. #13
    Registered User
    Join Date
    03-10-2010
    Location
    Italy
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Bubble chart with 5 dimension + label

    see attached image
    Attached Images Attached Images

  14. #14
    Registered User
    Join Date
    03-10-2010
    Location
    Italy
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Bubble chart with 5 dimension + label

    With the copy and paste update the plot is ok!...
    then we are on a dead end .....or is there another alternative with another event to change the cells?

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

    Re: Bubble chart with 5 dimension + label

    Yes the calculate event.

    But as I said previously with all those cells changing the update will take ages. as each time a cell changes the whole chart will upate.

  16. #16
    Registered User
    Join Date
    03-10-2010
    Location
    Italy
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Bubble chart with 5 dimension + label

    Hi Andy,

    I would like to know if you can include the legend in the bubble plots using a VBA code.
    In particular, the text that is contained in the 6 different cells of the range (R1: W1) should be linked to the 6 different colors of the matrix (R2: W7)
    Could you help me?

    Thanks
    Antonino


    I attach a dataset
    Attached Files Attached Files

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

    Re: Bubble chart with 5 dimension + label

    If you enable the legend you will see each point has an entry. This is because of the unique formatting applied to each series.

    If you then use the Source data dialog to add 5 dummy series the legend will then display the names of the new series.

    But how will the legend relate to the data points, seeing as each data point is unique in shape and colour?

  18. #18
    Registered User
    Join Date
    03-10-2010
    Location
    Italy
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Bubble chart with 5 dimension + label

    Hi Andy,
    probably in the previous mail, I did not explain myself clearly.
    The legend that I would like to create should not be linked to the data-source, but I would like that it could pick up individually the 6 shapes on the worksheet and then I could concatenate a text description.
    The result that comes out with vba should generate a sort of static image that shows to the reader that every point with that shape and that color belongs to category1, category2, etc.
    Thanks
    Antonino
    Attached Images Attached Images

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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