0

Data with X, Y values is plotted on as a scatter chart using the .NET 4.0 Chart control. I believe the Microsoft chart control was obtained from Dundas.

I would like to select points on the chart using a rubber-band rectangle similar to the rectangle that is used to zoom the chart. (When the first mouse button is clicked it establishes one corner of the rectangle, as the mouse moves the semi-transparent rectangle would be redrawn until the mouse is released).

Is there a way to override the zoom method to create a selection rather than zooming-in?

Can an overlay be placed over an existing chart that will catch the mouse clicks and display a transparent rectangle?

I usually like to post sample code with my questions, but in this case I don't know where to begin. Links to the correct spot in the documentation, other tutorials or example code would be appreciated.

TaW
  • 53,122
  • 8
  • 69
  • 111
DarwinIcesurfer
  • 1,073
  • 4
  • 25
  • 42

1 Answers1

0

Don't know if you still need help with this, I don't have any sample code but this is pretty much what i'd try:

  1. Use a Hit Test to capture the x/y values of the MouseDown event, and store this in a variable.
  2. Capture and store the x/y values of the MouseUp event in a similar way.
  3. Still in the MouseUp event, draw your rectangle using LineAnnotations with the two x/y values. Then interogate every datapoint in your series to see if it lies in the area bounded by the rectangle, and add the datapoint index to an array/list if it does. You will then have a list of all the points inside a dragged rectangle.

NB you will need to destroy the line annotations at some point, possibly when you start to drag a new rectangle.

Hope this helps. Nick

Nick
  • 685
  • 12
  • 27