Android Question xGraph Callback Function for the Cursor Position.

rgarnett1955

Active Member
Licensed User
Longtime User
Hi,

I use a xGraph to plot a lot of data against time and date. Generally trying to put times and dates together on each x axis tick is clumsy, complicated and often results in an illegible x axis.

What I normally do is have a label field with the start date/time string on the left hand x axis start point and a label with the end date/time on the right hand side of the x Axis. I then display the cursor value and convert it to a date/time string based on the index of the cursor and put that in a label positioned in the centre of the x axis. Sadly there doesn't seem to be a way of getting the x and y of the cursor values in xGraph at present. I wonder whether this feature could be added. Clicking on the chart's data area would generate the cursor as it does now, but it would also generate events on the click and cursor movement and capture the x y values.

What would be even cooler is that if you report which mouse key was used left/right so that differential values could be captured and displayed. Releasing the mouse button would of course turn off the mouse movement events.

Having such a function call back would open up a lot of possibilities for interacting with the graph.

I have attached a screen shot of one of my projects showing what I am getting at.

Best regards

Rob
 

Attachments

  • xGraphCursorCallback.png
    317.4 KB · Views: 253

rgarnett1955

Active Member
Licensed User
Longtime User
Hi Klaus

I got your reply about the xGraph cursors via email, but when i pushed the button to go to the post I could only see what I had written. I did a search and found an entry, but when I clicked on it it gave me an "oops" response. I couldn't get to your reply.

You idea regarding returning the co0ordinates is a good one. You could have a large number of Y values and one x value. Would the returned value be an array with the first value being the action the second being the x position and the rest being the y values?

I get what you are saying about the mouse buttons, cross platform etc so I'm wondering how you could capture more than one set of values. I guess if you added a button to the app which copied the values the app could calculate delta's etc. i.e.

- Click mouse button for cursor app records and returns x yy values and update a program variable with them
- Release mouse button
- Click a screen button to copy this reference set into another variable
- Click mouse button for cursor and do the calc with each mouse movement

There are probably other ways of doing this however having the callback event would allow a number of approaches.

Thanks for your prompt reply.

Best regards

Rob
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
It seems that my reply has disappeared.
I will return following parameters as a Type variable.
- Action
- X
- Y
- XIndex
- Array with the indexes of the displayed curves.
And I will Add these properties, read only: GraphLeft, GraphTop, GraphWidth and GraphHeigt, the coordinates, in pixels, of the grid in the xGraph view.

With these parameters and properties you can then do whatever you want.

I will also add two cursors, this was a request from another user here.
 
Upvote 0

rgarnett1955

Active Member
Licensed User
Longtime User
Hi Klaus,

That was funny your post disappearing.

Super! Two cursors would be great.

Just a question. If there is more than one trace would there be be more than one Y value at any X point?

Best regards

Rob
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Just a question. If there is more than one trace would there be be more than one Y value at any X point?
For the cursors, yes.
I will also add a CursorChanged event, returning its Index and its XIndex.
For the Touch event I will not return the array of displayed curves, it already does exist, the CurvesToDisplay property.
I will return only the variable parameters for a given graph.
With the XIndex and the displayed curve indexes you know all the Y values with something like this:
 
Upvote 0

rgarnett1955

Active Member
Licensed User
Longtime User
Hi Klaus,

I get it.

With the index you can retrieve the values. I thought that is the best way. Of course if the number of points per cm of screen is greater than the screen resolution then some indices won't be available, but this just mean to need to zoom in the x axis to bring the number of screen pixel/mouse points greater than the number of data x points.

Best regards
Rob
 
Upvote 0

rgarnett1955

Active Member
Licensed User
Longtime User
I hadn't mentioned that I have also added these two properties XIndexBegin and XIndexEnd these are the first and last visible indexes.

Hi Klaus,

So when you zoom these indices represent the start and end of the visible data?

That's excellent.

Best regards
Rob
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
@rgarnett1955
Can you please test the attached project?
New features:
Two cursors.
Management with missing data, you need to enter the 100000000.

 

Attachments

  • xGraphDemoV1_3.zip
    15 KB · Views: 264
  • xGraph.b4xlib
    12.3 KB · Views: 241
Upvote 0

rgarnett1955

Active Member
Licensed User
Longtime User
Hi Klaus,

Thanks for that. I was just ready to start that part of my project.

I will let you know how I get on.

Best regards

Rob
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…