Quinn-Curtis Forums
Quinn-Curtis Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Tools for Microsoft .Net & .Net Compact Framework
 QCChart2D and QCChart2D CF (VB and C#)
 Cursor position
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Benlehman

6 Posts

Posted - 26 Mar 2010 :  09:27:55  Show Profile  Reply with Quote
Is there a way to calculate the graph value based on where the cursor is? I am using SimpleScatterPlots and would like to have the ability for a user to hover over a point and it show the X and Y values for that point (obviously corresponding to the labels on the axis). Additionally I would like it to display the value of the cursor even if it is not hovering over a point. I know there are the chart labels but we have hundreds of thousands of points and our users do not want the labels to show within the chart itself. They just want a label on the bottom of the screen. I have looked a bit at the DataCursor class, but cant seem to find a way to make that do what I need.

Thanks always for the help!

quinncurtis

1164 Posts

Posted - 26 Mar 2010 :  11:10:42  Show Profile  Reply with Quote
The DataCursor class triggers on mouse button clicks, not mouse movement.

The easiest way to do what you describe is to add a mouse move event to the ChartView class a design time. Just double click on your ChartView derived class in the Solution Explorer to bring it up in Design Mode. In the Solution Explorer, under Properties, select the Event icon (lightning bolt) and double click the MouseMove event. That adds the shell of a mouse move event (DataCursors_MouseMove in the example below) to your ChartView derived class. Then just add code similar to what we show to get the current position of the mouse and convert it to physical coordinates, using ConvertCoord. Convert the (x,y) values to a string and assign it to a simple Systems.Windows.Forms.Label object, which has been previously added to the ChartView using the designer. In the example below, the pTransform1 variable is the CartesianCoordinates object used to display the chart, made global to the entire class.

.
.
private Label label1;
CartesianCoordinates pTransform1;

public DataCursors()
{
	// This call is required by the Windows Form Designer.
	InitializeComponent();

	// TODO: Add any initialization after the InitializeComponent call
	InitializeChart();
}

private void InitializeChart()
{
.
.
.

	pTransform1 = new CartesianCoordinates( ChartObj.LINEAR_SCALE, ChartObj.LINEAR_SCALE);
	pTransform1.AutoScale(datasetarray,  ChartObj.AUTOAXES_FAR, ChartObj.AUTOAXES_FAR);

.
.
.
}

 private void DataCursors_MouseMove(object sender, MouseEventArgs e)
 {
     Point2D mousepoint = new Point2D(e.X, e.Y);
     Point2D p = pTransform1.ConvertCoord(ChartObj.PHYS_POS, mousepoint, ChartObj.DEV_POS);
     String s = "x= " + p.X.ToString() + " y= " + p.Y.ToString();
     label1.Text = s;
 }

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Quinn-Curtis Forums © 2000-07 Quinn-Curtis, Inc. Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.07