Modifying Series in TDBChart

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Reinhard
Newbie
Newbie
Posts: 10
Joined: Fri Apr 22, 2005 4:00 am

Modifying Series in TDBChart

Post by Reinhard » Tue Jan 15, 2008 9:23 am

Hello,

I use Teechart Pro 7.12 VCL and I have a TDBChart connected to a DB.
If I want to display the values of the DB for example in p.u. I have to divide each y-value by a certain constant.
How can I do this?

thanks + regards
Reinhard

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Jan 15, 2008 9:56 am

Hi Reinhard,

Sorry but I don't understand what are you trying to achieve exactly. You could try doing something like the code below after populating your series.

Code: Select all

  for i:=0 to Series1.Count-1 do
  begin
    Series1.YValue[i] := Series1.YValue[i] / MyConst;
  end;
If that's not what you are looking for please give us some more details about your requirement.

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Reinhard
Newbie
Newbie
Posts: 10
Joined: Fri Apr 22, 2005 4:00 am

Post by Reinhard » Tue Jan 15, 2008 11:41 am

Hi Narcis,

the fact is, that my series depend on a DataSource.
The DataSource could be a TADODataSet (SQL), so I do not have direct access to the series values after refreshing it with CheckDataSource.
I just want to apply the constant just before displaying the y-values.

Regards, Reinhard

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

Post by Pep » Wed Jan 23, 2008 4:03 pm

Hi Reinhard,

what about using the OnBeforeDrawValues event :

Code: Select all

procedure TForm1.Series1BeforeDrawValues(Sender: TObject);
var i : integer;
begin
for i:=0 to Series1.Count do
  Series1.YValue[i] := Series1.YValue[i]  - (Series1.YValue[i] / 2);
end;
?

Another way would be to add the data values directly to your series by iterating through your Dataset by using the AddXY method. This way you will be able to add the modified data values too.

xxxxxx
Advanced
Posts: 128
Joined: Tue Jun 19, 2007 12:00 am
Location: Russia
Contact:

Post by xxxxxx » Thu Jan 24, 2008 7:00 pm

Hi, Pep!
What you suggested is a recursive scheme.
Don't you think such approach will result in dissapearing the whole series after several iterations with, say, zoom-unzoom?
Regards, Alexander
=================
TeeChart Pro v8.05, Delphi 5 & Turbo Delphi Professional for Win32., Delphi & C++Builder 2009

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Jan 25, 2008 9:49 am

Hi Alexander,

No, I don't think so if axes are set to automatic as they would automatically set their scales according to series values.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

xxxxxx
Advanced
Posts: 128
Joined: Tue Jun 19, 2007 12:00 am
Location: Russia
Contact:

Post by xxxxxx » Fri Jan 25, 2008 10:27 am

Hi, Narcís!
I meant

Code: Select all

limit ( Series1.YValue[i]) -> 0
:?:
Regards, Alexander
=================
TeeChart Pro v8.05, Delphi 5 & Turbo Delphi Professional for Win32., Delphi & C++Builder 2009

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Jan 25, 2008 11:16 am

Hi Alexander,

Yes, that's what I understood as well. However, if you divide all series points by the same ratio the ratio between them will be preserved too. So, if instead of being from 0 to 100 it's from 0 to 0.0001, axes will be automatically scaled to represent this.

Moreover, if Reinhard only wants this to happen the very first time the series are plotted then he could use a boolean flag to determine whether this code should be executed or not.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

xxxxxx
Advanced
Posts: 128
Joined: Tue Jun 19, 2007 12:00 am
Location: Russia
Contact:

Post by xxxxxx » Fri Jan 25, 2008 11:57 am

narcis wrote:Hi Alexander,

Yes, that's what I understood as well. However, if you divide all series points by the same ratio the ratio between them will be preserved too. So, if instead of being from 0 to 100 it's from 0 to 0.0001, axes will be automatically scaled to represent this.

Moreover, if Reinhard only wants this to happen the very first time the series are plotted then he could use a boolean flag to determine whether this code should be executed or not.
Thanks Narcis, I appreciate your valuable comments.
In't it possible to use OnAfterAdd event for scaling Series?
Regards, Alexander
=================
TeeChart Pro v8.05, Delphi 5 & Turbo Delphi Professional for Win32., Delphi & C++Builder 2009

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Jan 25, 2008 12:56 pm

Hi Alexander,

OnAfterAdd event doesn't work, you could do that in the chart's OnAfterDraw event, for example:

Code: Select all

procedure TForm1.Chart1AfterDraw(Sender: TObject);
var i : integer;
begin
  for i:=0 to Series1.Count do
    Series1.YValue[i] := Series1.YValue[i]  - (Series1.YValue[i] / 2);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.Draw;
end;
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply