03-21-2011 05:03 AM
Hi,
I have an application where I use several plots in the same graph (and several graphs stacked under each other). The x axis is a timeline constructed from with DateTime array, the y axis holds data values.
The previous version of this application used cursor to indicate the Y data value at a specified point in time (just by hovering the mouse, and snapping to the nearest point).
For the new version, it is preferable to hover the mouse, but be able to extract the Y values from all plots at the same time in a text box, like this:
Y data 1 value: 0.2
Y data 2 value: 1,4
Y data 3 value: 2.8
Y data 4 value: 8.3
At time 12/12-2008 08:00
I have tried all kinds of methods to extract the data at a specified time position, but they do not work as expected. I need input on how to obtain these values. I need something like (pseudo)
foreach (Plot plot in Graph.Plots)
double dataValueOfThisPlot = plot.GetDataAtTime(new DateTime(12, 12, 2008 ,. etc.....))
- Thanks a lot!
03-25-2011 02:50 AM
Here's a small update on this,
as you can see from the attached image I have 2 plots aligned over each other. The vertical bars follow the mouse when we are in "cursor navigation mode". The labels "CYCLIC_TIME" and FPULSE1 now show up with value NaN, I need to be able to retrieve the correct data values at the point in time where the mouse is.
I find the exact point in time of where the mouse is, but getting from there to actually getting out the values from different plots in the graph at that time instant does not seem easy to do with the current API.
I saw some tips somewhere about storing your own data vectors on the outside for lookup, but that is not feasible in this case because of the extra memory consumption. Also, direct lookup from stored media is not smart, as the raw data is stored in a zipped format...
Any input on this, anyone??
03-25-2011 10:32 AM
Hello -
I think the trick here is to let the cursor do the heavy lifting for you. The general idea is as follows:
Here's the important part of the code I wrote to get the associated screenshot:
NickB
National Instruments
03-29-2011 07:06 AM
Hi,
Thanks a lot, that works very well!
Is it also possible to obtain the exact time of the sample points (so I know which time stamp to assign each point)? I would think its available, since it snaps to the nearest data point, but cant quite see how to set up the cursor to retrieve this. The way your works now, the time used as input remains unchanged..
03-29-2011 08:46 AM
Hello -
Once you've set the XPosition property, you can then query the XPosition property again to see the value after the cursor has snapped to the nearest point on the associated plot. This will be a double value though, so it will need to be converted to a DateTime value. Maybe the easiest way to do that is through the DataConverter.Convert method.
Is that what you were asking?
NickB
National Instruments