Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

problems with plotxy function

I would like to plot some data on my graph not more than x[5000] y[5000, with chartxy called like this:

//CNiGraph graph;
    plotTrack = graph.Plots.Add();
    plotTrack.LineColor = CNiColor(0,102,255);
    plotTrack.LineWidth=4;
     
    plotTrack.chartXY(10,10);
    plotTrack.chartXY(10,20);
    plotTrack.chartXY(10,30);

 

I don't have any problem, but when I do insted of ChartXY

 
    plotTrack.PlotXY(10,10);
    plotTrack.PlotXY(10,20);
    plotTrack.PlotXY(10,30);

 

The graph is being scaled but nothing appears on it ;/

What's the problem?

0 Kudos
Message 1 of 7
(7,605 Views)

When you call the method PlotXY on a Plot object, old data will be overwritten. So if you call the method multiple times, only the last call will take affect. in your case, the last call is plotTrack.PlotXY(10,30). As this is only a single point, you do not see a line on your graph, but the graph is scalled to visualize the point.

If you want to add single points to a graph, you have to either use the chartXY method as you already did, or collect the data int two arrays and pass these with the PlotXY method.

 

Hope this helps!

 

André

 

0 Kudos
Message 2 of 7
(7,593 Views)
Could you give me some example code how to plot line (5000points) using plotxy? I can't find the proper overloaded method, and is it much faster than chartxy? Now when I'm drawing some points with chartxy the graph isn't updated when all points are added but point by point and it looks like animation and that's what I like to avoid, when I change it to plotxy is it going to be the same?
0 Kudos
Message 3 of 7
(7,591 Views)

 

I can understand that calling ChartXY 5000 times makes the application slow. PlotXY is much faster, as it updates the User Interface only once. What you have to do is store your data in a 2D array (double data[2,5000] in your case, and pass this variable. Here is an example with only 3 points:

 

double[,] mydata;

mydata = new double[2, 3];

mydata[0, 0] = 10;

mydata[0, 1] = 20;

mydata[0, 2] = 30;

mydata[1, 0] = 10;

mydata[1, 1] = 20;

mydata[1, 2] = 30;

axCWGraph1.PlotXY(mydata);

 

Message Edited by Andre_Saller on 08-29-2008 06:59 AM
0 Kudos
Message 4 of 7
(7,589 Views)
I'm using c++ and there's error that says that cannot convert data to cniarray ;/ Ok I created then CNiReal32Matrix but how the point are represented in this structure?
Message Edited by salad1985 on 08-29-2008 07:09 AM
0 Kudos
Message 5 of 7
(7,586 Views)

For example:

    CNiReal32Matrix mat;
    mat.SetSize(2,3);

 

I wold like to have points (10,10) (0,0) (-10,-10) connected with line...

 

Ok I got it, the usage of this class is very clear ;/

    CNiReal32Matrix mat;
    mat.SetSize(2,3);

    mat(0,1)=10.5;
    mat(1,1)=32;
   
    mat(0,2)=40.12;
    mat(1,2)=20.4;

Message Edited by salad1985 on 08-29-2008 07:26 AM
Message Edited by salad1985 on 08-29-2008 07:26 AM
0 Kudos
Message 6 of 7
(7,581 Views)
Sorry for writing message after message, but it's amazing fast ;] The way it should be ;]
0 Kudos
Message 7 of 7
(7,577 Views)