Jump to content
Software FX Community

Draw vertical line on chart on mouse move


lakshmimn

Recommended Posts

The verical line should be drawn on the chart when there is a mouse over event. It should act like a vertical pointer on the chart (the line should have the height as that of the chart), and the details of each of the data points (each point on X axis) on the chart, will be shown in a small popup window.

I tried the CustomGridLine, but this line does not move smoothly along each of the points on x axis, on mouse move it directly jumps to the next vertical line in the Grid.

Link to comment
Share on other sites

> I tried the CustomGridLine, but this line does not move smoothly along each of the points on x axis, on mouse move it directly jumps to

> the next vertical line in the Grid.

You can draw a custon gridline at any position in the axis, it does not have to be at one of the tickmarks/gridlines. If you were getting this behavior tit must be because something you were doing in the code that made it jump.

The following code, when included in the MouseMove event of a chart will produce a vertical gridline at the position of the mouse:

CustomGridLine

mousePointer;if (chart1.AxisX.CustomGridLines.Count == 0) {

mousePointer =

new CustomGridLine();mousePointer.Color = Color.Red;

// TODO: Any other customization you want to do the the gridline

chart1.AxisX.CustomGridLines.Add(mousePointer);

}

else

mousePointer = chart1.AxisX.CustomGridLines[0];

double

x = chart1.AxisX.PixelToValue(e.X);double min,max;

chart1.AxisX.GetScrollView(

out min, out max);x = Math.Min(x,max);

x =

Math.Max(x,min);

mousePointer.Value = x;

Link to comment
Share on other sites

  • 4 years later...

This is quite an old post now but I hope someone can help with this.

 I have managed to get the vertical line working when I move the mouse, however I would like to somehow determine all the points at which the vertical line intersects with the series that are currently plotted on the page.

 For example say I have 3 series that are being plotted, where the X axis is DateTime.

 As I move the mouse, how do I determine Y vlues of the intersection of the vertical line with the 3 series?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...