Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Scattergraph questions - minimum/maximum values and scientific mode

Hi, all!

I am using Measurement Studio 8.9 and developing a tool in C# to log and display signals.

 

1. First I wonder if there is any simple way to zoom back to the entire plot/s within a scattergraph? Once the user starts zooming back/forth I'd like to go back to a view containing the entire plots (like zooming to min X/Y and max X/Y). Is there a way to do this or do I need to store currentMaxX, currentMinY, etc ?

 

2. While zooming a lot the values on the scale turns into scientific mode (e.g.. 8.7957E+05 etc), is there a way to prohibit this, id like to use normal numbers as far as possible.

 

3. What possibilities do you have to access statistics using two cursors? I'd like to present values like min/max for a range over one/several plots. I reckon I need to be able to access/iterate individual values for this? This question is related to the first question

 

4. Doe anybody know when storing the scattergraph to a bitmap-file, if there is any chance to also include the X and Y-axis and possibly legends and labels perhaps?

 

Best regards,

Björn Nilsson

0 Kudos
Message 1 of 4
(3,871 Views)

Regarding #1 I used the GetXData()/GetYData() to retrieve the bounds of a plot, by iterating all plots I could construct a range including all plots

Regarding #3 The cursors must point out a subset of the values, by taking the cursor positions I could somehow calculate the indexes of the plot values and iterate through all those values to retrieve the subset min and max. Sounds like slow operation however!?

 

Reply to #2 and #4 is still welcome!

/BN

0 Kudos
Message 2 of 4
(3,861 Views)

I've solved my own question #2; i had to set the EditRangeNumericFormatMode to "Generic; N0" along with the labelformat for MajortDivisions to the same. N forces the formatting to always use numerical values (i.e. non scientific 😉 while default G, uses either nuerical or scientific depending on the size.

 

To summarize I still need help with quesiton #4 and regarding question #1 I havent yet manage to map a specific cursor position to an index of the values (GetDataX/GetDataY) of the plot. The cursor positions should define the range within a plot where I could try to find the min and max values of that plot.

 

There are some mapping funcitons like MapDataPoints but I havent been able to get the ranges correct, anybody?

0 Kudos
Message 3 of 4
(3,810 Views)

Hi there,

 

#1) You can set range on your own on an event like control+shift+alt+mouseClick (just an example). Try setting the axis mode to AutoScaleLose. This will by default draw the graph so that the plot is fully visible.

 

#2) Look at the SimpleAnnotation example (Examples\UI\WindowsForms\Graph\SimpleAnnotations\cs). This might give u some idea on how to do it for the Cursors. Use XPosition and YPosition properties of the XYCursor to position the cursor correctly.

 

#3)You can derive a class from XYCursor and have those properties.

 

#4) The following code could be what you are looking for. Modify as it suites you,

 

 

        private void button1_Click(object sender, EventArgs e)
{
using (Bitmap bmp = new Bitmap(Width, Height))
{
// Create a graphics object from a bitmap of size you want.
Graphics graphics = Graphics.FromImage(bmp);

// Draw using this Graphics object as shown below.
// You can draw graphs, or axes or legends this way.
waveformGraph.Draw(new ComponentDrawArgs(graphics, waveformGraph.Bounds));

bmp.Save(@"c:\1.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
}
}

 

Reply back if you need more help. Please explain the requirment in more detail so that we can help you effectively.

 

Regards,

Vijet Patankar,

National Instruments

 

 

0 Kudos
Message 4 of 4
(3,699 Views)