08-28-2008 02:57 AM
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?
08-29-2008 05:18 AM
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é
08-29-2008 06:08 AM
08-29-2008 06:58 AM - edited 08-29-2008 06:59 AM
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);
08-29-2008 07:05 AM - edited 08-29-2008 07:09 AM
08-29-2008 07:23 AM - edited 08-29-2008 07:26 AM
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;
08-29-2008 07:42 AM