Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

How to plot data using PlotXvsY method from the AxCWGraph object?

Hi,
 
I have searched through the tutoriols, knowledge base section, and forums for anything dealing with plotting points using the AxCWGraph object available for measurement studios 7.0 for VC++ .NET.
 
So far, I have found nothing on the topic except example code which I can not comprehend (because they use MFC classes, which my current project can not use). The main function I want to use is the PlotXvsY method made available for the class.
Apparently the method can take two parameters, x and y values to plot. But it wants of type System::Objects __gc for its parameters.
 
I looked at the examples which came with the software, and they all use CNiVectors to pass it in, which I understand belong to MFC classes. I was told I can not currently use the CNi class because my project isnt using MFC. Regardless, I was wondering if you can suggest me a way (hopefully easier to understand) on how to use PlotXvsY. I currently have an 1D array which holds floats and I just want to plot them onto the graph (AxCWGraph object). I hope this is clear enough on what I am trying to ask. I GREATLY appreciate the efforts and any help would be helpful. Thank you.
0 Kudos
Message 1 of 13
(5,746 Views)

If you are going to create an application using C++, .NET Windows Forms, and Measurement Studio, you have two choices to plot a 1D array of floats:

  1. Use an interop wrapper around the CWGraph control and plot an array of .NET data values via the PlotY method. You asked about PlotXvsY, but this method is for when you're specifying both the array of x values and the array of y values. Since you have 1 array, you should use PlotY instead of PlotXvsY.
  2. Convert the array of float values to an array of double values, then use the native Measurement Studio .NET Windows Forms WaveformGraph control to plot the array via the PlotY method.

Here is an example of using AxCWGraph.PlotXY:

float values __gc[] = { 1.0, 2.0, 1.0, 2.0, 1.0 } ;
axCWGraph1->PlotY(values);

Here is an equivalent example using WaveformGraph.PlotY:

float values __gc[] = { 1.0, 2.0, 1.0, 2.0, 1.0 } ;
double convertedValues __gc[] = (double __gc[])DataConverter::Convert(values, __typeof(double __gc[]));
waveformGraph1->PlotY(convertedValues);

Hope this helps.

- Elton

0 Kudos
Message 2 of 13
(5,723 Views)
Hi,
 
Thank you very much Elton. I forgot to mention my 1D array has x,y values respectively. I would jsut re organize it so I can have 2 arrays for x and y respecitively of type double and pass that into PlotXvsY.
I am assuming PlotXvsY(double x __gc[], double y __gc[]) works also?
 
Thanks!!
0 Kudos
Message 3 of 13
(5,723 Views)

Yes, that will work.  If you want to use the native Measurement Studio .NET UI Windows Forms control, you can use ScatterGraph.PlotXY.  Just out of curiosity, is there a reason that you are using an interop wrapper for the CWGraph control rather than using the native Measurement Studio .NET Windows Forms controls?

- Elton

0 Kudos
Message 4 of 13
(5,716 Views)

Hi Elton,

I hope you can read this again. How would I access Scattergraph controls in Visual C++.net?

I current have Measurement Studios 7.0 and only have AxCWGraph class when I create the graph UI.

I do want to use the PlotXY method, but the prototype for it is PlotXY(Object * __gc, Object* __gc)

I am assuming Scattergraph is PlotXY(double x, double y), which I want to use.

Thanks alot!

0 Kudos
Message 5 of 13
(5,680 Views)

ScatterGraph has PlotXY(double x, double y) and PlotXY(double[], double[]). Did you install the Measurement Studio .NET libraries when you installed Measurement Studio? If so, when you open the Windows Forms designer in a Managed C++ project, look at the toolbox and you should see a tab for the Measurement Studio .NET controls. Open this tab and you will see ScatterGraph, and then you can drag and drop a ScatterGraph to the form.

- Elton

0 Kudos
Message 6 of 13
(5,674 Views)
Thank you for the prompt response.
I probably did not install the measurement studio .NET libraries. But just to make sure.
Right now in my toolbox under measurement studio tab, I only see CW UI Objects, i.e. CWSlide, CWknob, CWGraph, etc..
 
So your saying under the measurement studio tab I should see a "scatter graph" object. Sorry I am new to measurement studios. Thanks!
0 Kudos
Message 7 of 13
(5,672 Views)

There are two toolbox tabs: one for Measurement Studio C++ controls and another for Measurement Studio .NET controls. The Measurement Studio C++ tab has CWGraph, CWSlide, etc. The Measurement Studio .NET tab has ScatterGraph, WaveformGraph, etc. If you do not see the Measurement Studio .NET tab, then you probably do not have the Measurement Studio .NET libraries installed. You can double-check your Measurement Studio installation directory to be sure. If the Measurement Studio .NET libraries are installed and the toolbox tab is not appearing, you can create the toolbox tab yourself and add the controls from the NationalInstruments.UI.WindowsForms.dll assembly in the Measurement Studio installation directory.

- Elton

0 Kudos
Message 8 of 13
(5,666 Views)
Hi Elton,
 
I added the NationalInstruments.UI.WindowsForms.dll assembly file after installing the .NET libraries. Unless I installed it wrong, I only see the waveform graph object, and not scatter graph. I currently have the Developer Suite 2004, which should include the libraries that contains the Scatter graph object I am assuming.
Again, the reason why I want to use Scatter Graph is to use the method PlotXY, and waveform graph does not have any plot methods that are useful, i.e.  PlotX, PlotY, PlotXappend, PlotYappend
 
When I added the toolbar manually and add the items for it, I do see the NI UI.WindowsForms.dll assembly file. I chose it and clicked OK, and only the waveform graph object showed up. Any help would be greatly appreciated. Thanks!
0 Kudos
Message 9 of 13
(5,598 Views)

Nevermind, I found out what was wrong. Did not look close enough to find the scatter graph object. Sorry to bother you! thanks!

0 Kudos
Message 10 of 13
(5,596 Views)