TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
-
tbonejo
- Newbie
- Posts: 73
- Joined: Wed Sep 06, 2006 12:00 am
-
Contact:
Post
by tbonejo » Tue Nov 14, 2006 6:57 pm
Hi,
I am using the AddXY method to load series dynamically with data from TMS AdvStringGrid. It loads the data ok, but the values at the beginning of the plot are not correct. I tried doing arrays but because my charts and series are unknown at design time, I cant really seem to load the data the same as using the AddXY method.
Has anyone else experienced strange data plots using AddXY?
Heres an idea of what my code looks like:
Code: Select all
Procedure getChartdata(grid: TAdvColumnGrid; ChartPanel: TTeePreviewPanel; mychart: Array of TChart; check: TOfficeHintCheckBoxXP);
Var
mycol,myrow: Integer;
idx,i : integer;
begin
for idx := 0 to Charts-1 do
begin
for mycol := 0 to grid.TotalColCount-1 do
begin
s := grid.Cells[mycol,startrow-1];
for myrow := startrow to endrow do
begin
xser := grid.Floats[0,myrow];
yser := grid.Floats[mycol,myrow];
mychart[idx].Series[mycol].AddXY(xser,yser,s);
end;
end;
if check.Checked = True then
begin
mychart[idx].Title.Caption := run + ' ' + filename + ' ' + grid.Cells[0,2] + grid.cells[1,2];
end
else
mychart[idx].Title.Caption := run + ' ' + filename;
mychart[idx].Axes.Bottom.LabelStyle:=talValue;
end;
end;
thanks,
Tom
Tom
-
tbonejo
- Newbie
- Posts: 73
- Joined: Wed Sep 06, 2006 12:00 am
-
Contact:
Post
by tbonejo » Tue Nov 14, 2006 7:31 pm
I also noticed if I use arrays and do the with stuff for setting the values and all, that works fine but the only plot I see is the last one done?
Code: Select all
With mychart[idx].Series[mycol].XValues do
begin
Value:=TChartValues(mytime); { <-- the array }
Count:=myrow; { <-- number of points }
Modified:=true;
end;
With mychart[idx].Series[mycol].YValues do
begin
Value:=TChartValues(myseries);
Count:=myrow;
Modified:=true;
end;
Tom
-
tbonejo
- Newbie
- Posts: 73
- Joined: Wed Sep 06, 2006 12:00 am
-
Contact:
Post
by tbonejo » Wed Nov 15, 2006 2:55 am
Seems strange but if I create the series first and then do the addxy it works fine. However if I already created the series elsewhere and THEN do the addxy it shows incorrect data.
Any ideas?
Thanks,
Tom
Tom
-
tbonejo
- Newbie
- Posts: 73
- Joined: Wed Sep 06, 2006 12:00 am
-
Contact:
Post
by tbonejo » Wed Nov 15, 2006 2:58 pm
Can someone give me a hand with this?
Its getting awful frustrating wasting hours trying to get this resolved.
How hard can it be?
Tom
-
tbonejo
- Newbie
- Posts: 73
- Joined: Wed Sep 06, 2006 12:00 am
-
Contact:
Post
by tbonejo » Wed Nov 15, 2006 4:54 pm
Doesnt anyone have a clue here?
Ive rewritten code 30 times over trying to get this corrected.
Sorry if Im losing my patience but this is driving me nuts trying to get it working the way one would expect it to.
Thanks,
Tom
Tom
-
tbonejo
- Newbie
- Posts: 73
- Joined: Wed Sep 06, 2006 12:00 am
-
Contact:
Post
by tbonejo » Thu Nov 16, 2006 12:13 pm
For those watching I resolved this issue.
Remember when you create series at runtime, dont forget to clear the data BEFORE doing the ADdXY, especially if for looks you use the fillsamples function!
That was the unexplained numbers all along.
Tom
Tom