Page 1 of 1

Dynamic Data Link using C++.

Posted: Tue Apr 20, 2004 8:04 am
by 9232129
How do I dynamically link an array of data using c++? The following doesn't work.

double *X;
X = new double[my_total_pts];
series1->YValues->Value = TChartValues(X); //this was in the hlp doc.


Everytime I update my data array, I want the graph update done. Every time I drag a point on the graph, I want the array updated. Any ideas?
Can someone point me to a good example? ? Thanks!

Posted: Tue Apr 20, 2004 6:05 pm
by Pep
Hi,
How do I dynamically link an array of data using c++? The following doesn't work.
You can use the AddArray method. You can see some examples of use in the TeeChart Pro Demo Features project.
i.e :

Code: Select all

double vals1[6] = {3,6,8,15,19,21};
Series1->AddArray(vals1,5);
Everytime I update my data array, I want the graph update done. Every time I drag a point on the graph, I want the array updated. Any ideas?
To update the Chart my best suggestion is that you run the AddArray() method after having made changes to the array. About the "drag point" you can update the Array using the OnDragPoint event of the DragPoint tool.

Posted: Wed Apr 21, 2004 4:53 am
by 9232129
Ok, I'm fine with AddArray. Got that working great for loading the data.
Now, when I look at the Tea Tree Pro 7 demo that attempts to illustrate source code for coding OnDragPoint, it keeps asking me for a sample directory. Where is this supposed to be??? I don't seem to have it.
Thanks again. Almost there...

Posted: Wed Apr 21, 2004 4:58 am
by 9232129
Ok, I see where I can intercept the drag event using a user defined DragPointEvent.

Keep in mind I've only had this library for 2 days, so I'm still learning about it. :D

Now, I still don't see how I can grab the data from the TChartGrid and copy to my double array. How do I grab data from TChartGrid?? Ultimately,
I guess I should be read/writing ChartGrid as my source, but how do I access it??

Posted: Wed Apr 21, 2004 7:28 am
by 9232129
Is this all TeeChart legal?

double *X,*Y;

X = new double[npts];
Y = new double[npts];

//read in X,Y data from bin file.

//clear series
series1->Clear();

//copy block data to Y series
series1->AddArray(Y,npts);

//same idea, but is this ok??? 8 bytes/pt
memcpy(&series1->YValues->Value[0],Y,npts*8);

//set npts; is this necessary if AddArray is used??
series1->XValues->Count = npts;

//set x values; is this ok????????
for (int i=0;i<npts;i++)
series1->XValues->Value = X;


//Last if setting data is not accepted using memcpy, is retrieving it ok??
memcpy(X,&series1->YValues->Value[0],npts*8);


...

Problem: If I clear the series "series1->Clear()", then AddArray for Y data, X coordinates are lost. How do I add back X data or will the methods I listed above work ok??


THANKS!