How to use (and move) a vertical line as a cursor in x-y plot

R

Rick Jones

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
 
J

Jon Peltier

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top