Dynamic Data Link using C++.

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
pbooth
Newbie
Newbie
Posts: 9
Joined: Mon Apr 19, 2004 4:00 am
Location: Folsom, CA

Dynamic Data Link using C++.

Post by pbooth » Tue Apr 20, 2004 8:04 am

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!

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Tue Apr 20, 2004 6:05 pm

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.

pbooth
Newbie
Newbie
Posts: 9
Joined: Mon Apr 19, 2004 4:00 am
Location: Folsom, CA

Post by pbooth » Wed Apr 21, 2004 4:53 am

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...

pbooth
Newbie
Newbie
Posts: 9
Joined: Mon Apr 19, 2004 4:00 am
Location: Folsom, CA

Post by pbooth » Wed Apr 21, 2004 4:58 am

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??

pbooth
Newbie
Newbie
Posts: 9
Joined: Mon Apr 19, 2004 4:00 am
Location: Folsom, CA

Post by pbooth » Wed Apr 21, 2004 7:28 am

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!

Post Reply