+ Reply to Thread
Results 1 to 33 of 33

Scatter Graph questions

  1. #1
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Scatter Graph questions

    Hi all

    I have a spreadsheet which ranks customers gold, silver and bronze based on their profit. I now want to populate this on a scatter graph but have some questions as this is the most complicated graph I have created:
    1. Is there any way in which I can show the marker colours the same as my classification of the customer e.g. if I have ranked the customer as gold then I would like the marker colour to be gold also. I know you can do this manually but I have over 600 of these to do and that way is too time consuming
    2. I want to be able to hover over the marker and for it to show the customer name, is this possible
    3. How do I plot an average line

    Please note I have a selection box where the end user selects what the graph needs to show e.g. show gold and silver customers only (this currently isn’t working).

    I have attached an example...

    In mine I have profit on the Y axis and Sales on the X axis but I need this switched

    Any suggestions how I achieve this?

    Regards

    Paul
    Attached Files Attached Files

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Scatter Graph questions

    this may help with some of it-it plots three separate series and also skips any series if the checkbox isn't selected. the colors aren't too good but you can change them.
    Attached Files Attached Files
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  3. #3
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Scatter Graph questions

    Excellent - I thought I would have had to rearrange the data in someway - thanks!!

    I have two further questions.....
    1. Does anyone know of a way (or a VBA code) which will display the customer name (column B) when you hover over the point on the actual graph?
    2. How do I plot an average line?

    I have updated the file...
    Attached Files Attached Files

  4. #4
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Scatter Graph questions

    you could get hold of the XY labeller addin-which is free- to add datalabels to the chart but if you want just hovering I think you'd need a class to trap the chart's events.
    what average do you want to plot?

  5. #5
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Scatter Graph questions

    I would want a line to go through the chart to show average sales 51.05 (average of D27:D46)

    What is a class that traps the charts events?

  6. #6
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Scatter Graph questions

    I have found this link:
    HTML Code: 
    I can not get the code to work for me, any help?

  7. #7
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Scatter Graph questions

    here's an example. you need to actually click to select the chart then just mouse over the point you are interested in.
    Attached Files Attached Files

  8. #8
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Scatter Graph questions

    Wow - i was getting into a real mess following that link i posted.

    In order to get the data labels showing is this the only code needed?
    Please Login or Register  to view this content.
    did you have to do anything else to get it to work as i have to replicate this on another sheet e.g. are there any named ranges etc?

    ps a HUGE thank you for helping me with this

  9. #9
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Scatter Graph questions

    oh yeah-I forgot that. I named the customer cells "Customers"

  10. #10
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Scatter Graph questions

    ok excellent - I will rename my new range customers as i have alot more than the 20 that i posted in the example

  11. #11
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Scatter Graph questions

    Hi,

    I have plotted the chart (a huge thank you) but it isnt as appealing as i hoped for as it is very clustered.

    I have used a logarithmic scale on one of the axis however I can not do so on the other as it doesn’t plot negative values - just wondered if you (or anyone else) know any tricks that would display this any better?

    Uploaded the latest file
    Attached Files Attached Files

  12. #12
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Scatter Graph questions

    Hi,

    I have created a new sheet to plot a scatter graph for products (previously it was customers) I have adapted the code to:
    Please Login or Register  to view this content.
    but it isnt working - am i doing something wrong? i have added the named range products
    Last edited by pauldaddyadams; 05-09-2012 at 11:34 AM.

  13. #13
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Scatter Graph questions

    did you run the setchart sub for that sheet? (I had added code in the workbook_open event of my file to run that sub for the original sheet)

    btw I would make a change to the original code
    Please Login or Register  to view this content.
    to make sure the datalabels always get deleted again

  14. #14
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Scatter Graph questions

    Hi,

    i have updated the code with the new one above but this no longer works for the customer sheet?

    The product sheet, what do I need to do in the workbook open even? Currently it is:
    Please Login or Register  to view this content.
    Last edited by Paul; 05-09-2012 at 06:45 PM. Reason: Added CODE tags!

  15. #15
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Scatter Graph questions

    assuming code name of other sheet is Sheet2
    Please Login or Register  to view this content.
    if you reopen the workbook (or just run that sub) both charts should respond to events again

  16. #16
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Scatter Graph questions

    I have tried that and I get a debug error

  17. #17
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Scatter Graph questions

    This is the code that I have:

    Code on this workbook:
    Please Login or Register  to view this content.
    Code on Sheet1:
    Please Login or Register  to view this content.
    Code on sheet 2
    Please Login or Register  to view this content.

  18. #18
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Scatter Graph questions

    where is the error? if it's in the workbook_open then the codename is wrong. you can use the sheet name
    Please Login or Register  to view this content.
    instead

  19. #19
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Scatter Graph questions

    Sorry, what would be the full code I would need in the Wookbook sheet? I'm a complete rookie with vba

    Do the codes I have on sheet1 and sheet2 look ok as they differ slightly

  20. #20
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Scatter Graph questions

    the code on sheet2 should be exactly the same as the code on sheet1

  21. #21
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Scatter Graph questions

    This may be where I am going wrong, I will try later tonight when i am home

  22. #22
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Scatter Graph questions

    I have the customer sheet working but I have this highlighted in yellow as an error:
    Please Login or Register  to view this content.
    which means the lables are not appearing on the product sheet (sheet2) scatter graph


    This is all the code I have:

    This Workbook
    Please Login or Register  to view this content.
    Sheet 1:
    Please Login or Register  to view this content.

    Sheet 2
    Please Login or Register  to view this content.
    Where am I going wrong?

  23. #23
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Scatter Graph questions

    what is the error message?

  24. #24
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Scatter Graph questions

    I changed the worksheet code to:
    Please Login or Register  to view this content.
    And it seems to be working up to a point but I still get the error:
    "cht.GetChartElement x, y, element, a, b"

    Which is on the Aintree Products sheet in VB

  25. #25
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Scatter Graph questions

    what error?

  26. #26
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Scatter Graph questions

    It says:
    Run-time error 50290

    Method 'get chart element' og object '_chart' failed

    Then then following bit is highlighted in VB as yellow "cht.GetChartElement x, y, element, a, b"

  27. #27
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Scatter Graph questions

    no idea-would need to see workbook

  28. #28
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Scatter Graph questions

    Ok, i will upload the workbook - I just need to remove sensitive data.

    I also get this error which seems to crash the sheet: Negative or zero values cannot be plotted correctly on log charts. Only positive values can be interpreted on a logarithmic scale.Can I turn this off?

  29. #29
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Scatter Graph questions

    simple way would be to replace any zero values with very small positives like 0.0001

  30. #30
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Scatter Graph questions

    Please see the attached updated file
    Attached Files Attached Files

  31. #31
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Scatter Graph questions

    I have client work to do now but will try and check the file out tonight.

  32. #32
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Scatter Graph questions

    Thanks JosephP - really greatful for the help!!

    Paul

  33. #33
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,689

    Re: Scatter Graph questions

    JosephP - when i changed the zero and negative values it seemed to work. i think the graph was causing my spreadsheet to crash.

+ 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