PDA

View Full Version : Solved: XY chart with values on top of each other



mikke3141
07-22-2010, 12:18 AM
Hello,

I have the attached dynamic XY chart and when I click or double-click the person in the grid, some information is shown in a message box. However if there are two or more persons in the same position, only one value is shown in the message box. Is there a way to solve this issue? Also ideas to improve the code are appreciated.

p45cal
07-22-2010, 11:09 AM
Since events occur when either the point or the datalabel is (double-)clicked, you could place the datalabels so that they don't completely overlap each other when there are two points the same. I realise you've posted an xls file, but are you running this on xl2007 or earlier? It makes quite a difference.

In general terms, there are datalabels which can be reached in at least two ways:
Worksheets("sheet1").ChartObjects(1).Chart.SeriesCollection(1).DataLabels(2)
or:
Worksheets("sheet1").ChartObjects(1).Chart.SeriesCollection(1).Points(2).DataLabel

They have .top and a .left properties amongst others (orientation,position).
It could be a case of checking each one's position and if overlaps occur, offsetting any that do until overlap is reduced or eliminated - that way, all labeles would be available to click on.

mikke3141
07-22-2010, 11:16 PM
Thank you for your answer. I will try this. :cool: