ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Fixed Data Points
Posted by Florian Heck on Mar-01-2019 18:31
Hello Support-Team,

I am using the Example "Zooming and Scrolling with Track Line (1) (Windows)" and I'm already impressed by ChartDirector.

But now I'm trying to implement 2 fixed Data-Points when I clicked the Mouse twice or better clicked the Left and then the right Button.

But everytime I created a fixed Data-Point I think the command

Dim d As DrawArea = c.initDynamicLayer()

delete the Data-Point! Is this right?

So my question: Is there a way to implement two fixed Data-Points and delete them just by clicking again or press a refresh button?

Thanks for your help!

Kind regards

  Re: Fixed Data Points
Posted by Peter Kwan on Mar-01-2019 23:07
Hi Florian,

I happened to have a simple example that as follows:

- The user can drag a line on the chart. The line will have two end points represented as two small rectangles.

- The user can drag the individual rectangles and hence change the line.

The original intention of the above is to provide a "ruler" or measurement interface on the chart. (The line is the ruler.) We wrote that for one of our customers and it is in C++/MFC. Our customer then modifies it to display the position, length and slope of the line segment somewhere in their user interface.

If the above is similar to what you need, I can port the code to VB on Windows Forms for you.

For your enquiry, it is correct that the "initDynamicLayer" will clear the dynamic layer.

In the sample code, you may notice there are already multiple circle points on the "track cursor". So to draw two fixed points, you just need to draw two fixed points after initDynamicLayer. Basically, your code needs to keep track of how many points you need to draw, and draw them.

As a simple example, your code can maintain the coordinates (x1, y1) and (x2, y2) for the position of the two points, and initialize them to (-999, -999) (or any invalid coordinates). In the code after initDynamicLayer, your code draws (x1, y1) and (x2, y2) only if they are valid coordinates.

When the user clicks on the plotarea, you may check if the mouse is on (x1, y1) or (x2, y2). If the mouse is not on either point and at least one of the points are invalid, then assign the mouse coordinates to the invalid point. This adds a point to the chart. If the mouse is clicked on a valid point, then assign invalid coordinates to that point. This removes the point. Then redraw the dynamic layer to update the display.

Peter Kwan

  Re: Fixed Data Points
Posted by Florian Heck on Mar-08-2019 17:31
Hi Peter,

thank you for your help and the description in detail!

With the idea to maintain the coordinates (x1, y1) and (x2, y2) for the position of the two points, and initialize them to (-999, -999) it works really good!
My program set one point with a left click and the other one with the right click. So the program save the coordinates and draw the fixed points everytime it draws the moving point.

So thank you again for the fast support!

Best regards,