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#)
 Mouseover events for bar and points
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Mark

2 Posts

Posted - 08 Apr 2005 :  13:54:55  Show Profile  Reply with Quote
I would like to detect mouse over for the individual bar on a bar char and point on a line plot. Is this possible? I can of'course detect mouse over the graph, but how can I determine which bar for example the mouse is over.

quinncurtis

1164 Posts

Posted - 08 Apr 2005 :  15:13:54  Show Profile  Reply with Quote
There are many ways to do this, using our MouseListener, DataToolTip, FindObj, DataCursor classes. A simple, direct way to do this is to just override the OnMouseDown event of the ChartView class you are using to display the plots, and use the plot objects CheckIntersection method to test for a hit and to get the selected data point index, as seen below. The thePlot1 object is an instantiated SimpleLinePlot, or SimpleBarPlot object. You could also override the ChartView.OnMouseUp or ChartView.OnMouseMove events in the same manner.

public class SimpleBarChart : com.quinncurtis.chart2dnet.ChartView
{
SimpleBarPlot thePlot1;


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

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

private void InitializeChart()
{
ChartView chartVu = this;
.
.
.

}

protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
{
Point2D testpoint = new Point2D(e.X, e.Y);
NearestPointData np = new NearestPointData();
int selectedbarindex = -1;
if ( thePlot1.CheckIntersection( testpoint, np))
{
selectedbarindex = np.NearestPointIndex;
}

base.OnMouseDown(e);
}


}
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