If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
How to use (and move) a vertical line as a cursor in x-y plot
I think I have a big job ahead of me but before I invest too much time I'm
wondering if it can be done at all. I would like to have an x-y graph where I have plotted the outside contour of some object (for discussion purposes it is the side view of a rocket ship). I would like to have a vertical line in this plot that can be moved left or right within the plot area (but not allowed to go out of this area) using the cursor (left mouse button) such that when I release the button, the x position of the vertical line is linked to a cell in the worksheet. This x value would also be shown adjacent to the line as the line is moved. This x value is then used in a lookup table to get data to graph (in a second graph) the diameter of the rocket ship at that x position. The part that I don't know how to do is what type of line do I use, how to move this line around, make sure the line cannot be dragged out of the plot area (assumes the line is a drawn object and not a second data series), and how to get the x position (as well as link it to the cell) when I release the mouse button. It would be nice if the mouse button were to change shape to a double headed, horizontal arrow when it was over the vertical line (and the line could only be moved when the cursur was this horizontal arrow). I have been somewhat successful in accomplishing the above goal but using a less eloquent solution. To obtain the vertical line, I plotted a second series (2 pts having the same x value and y values that were low and high enough that the connecting line spanned the plot area). I utilized a horizontal scroll bar linked to a cell to change the x value of the second series. Moving the scroll bar moves the vertical line real time but the plot flashes like crazy - extremely annoying. It works ... but for this engineering application I would much rather move the line with the cursor and not have have the graph flashing at the user. Thanks, Rick |
#2
|
|||
|
|||
How to use (and move) a vertical line as a cursor in x-y plot
Rick -
Until I got to the end of your post, I was going to suggest the solution you came up with. To use the cursor to move the line, you need to use chart events. This is easy on a chart sheet, somewhat more difficult in an embedded chart. The MouseMove event tells you when the cursor moves, and gives you the X,Y coordinates of the cursor, in points from the top left corner of the chart. A little algebra, using the axis scales and the plot area's inside dimensions tell you what the X values for the second series must be. - Jon ------- Jon Peltier, Microsoft Excel MVP http://www.geocities.com/jonpeltier/Excel/index.html _______ Rick Jones wrote: I think I have a big job ahead of me but before I invest too much time I'm wondering if it can be done at all. I would like to have an x-y graph where I have plotted the outside contour of some object (for discussion purposes it is the side view of a rocket ship). I would like to have a vertical line in this plot that can be moved left or right within the plot area (but not allowed to go out of this area) using the cursor (left mouse button) such that when I release the button, the x position of the vertical line is linked to a cell in the worksheet. This x value would also be shown adjacent to the line as the line is moved. This x value is then used in a lookup table to get data to graph (in a second graph) the diameter of the rocket ship at that x position. The part that I don't know how to do is what type of line do I use, how to move this line around, make sure the line cannot be dragged out of the plot area (assumes the line is a drawn object and not a second data series), and how to get the x position (as well as link it to the cell) when I release the mouse button. It would be nice if the mouse button were to change shape to a double headed, horizontal arrow when it was over the vertical line (and the line could only be moved when the cursur was this horizontal arrow). I have been somewhat successful in accomplishing the above goal but using a less eloquent solution. To obtain the vertical line, I plotted a second series (2 pts having the same x value and y values that were low and high enough that the connecting line spanned the plot area). I utilized a horizontal scroll bar linked to a cell to change the x value of the second series. Moving the scroll bar moves the vertical line real time but the plot flashes like crazy - extremely annoying. It works ... but for this engineering application I would much rather move the line with the cursor and not have have the graph flashing at the user. Thanks, Rick |
Thread Tools | |
Display Modes | |
|
|