Declaring Chart.Series as a variable on another unit

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
myghetto
Newbie
Newbie
Posts: 27
Joined: Thu Oct 05, 2006 12:00 am

Declaring Chart.Series as a variable on another unit

Post by myghetto » Thu Jul 26, 2007 1:03 am

Hi,
I am currently trying to use Chart 3

Code: Select all

type
  TForm1 = class(TForm)
    Chart3: TChart;
in a separate unit which is linked to the main with the above code already in the main unit. In the separate unit, I am trying to use code such as

Code: Select all

Chart3.Series[0].Clear;
Chart3.Series[0].AddXY;
I was wondering what kind of var or uses inorder for me to do that successfully because currently I am getting an Undeclared identifier error.

Thank you.

David

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

Post by Pep » Thu Jul 26, 2007 8:41 am

Hi David,

simply adding the unit name where the Chart is placed to the uses section should be sufficient.

myghetto
Newbie
Newbie
Posts: 27
Joined: Thu Oct 05, 2006 12:00 am

Post by myghetto » Thu Jul 26, 2007 11:22 pm

Hi,
I have done that and tried putting the unit name before and after the implementation section. It still doesn't work. I suspect its something you have to declare?

myghetto
Newbie
Newbie
Posts: 27
Joined: Thu Oct 05, 2006 12:00 am

Post by myghetto » Thu Jul 26, 2007 11:45 pm

This is my code below. The headunit is the main unit. data_plotting is the second unit. The chart3...... all have undeclared identifier. I was thinking maybe I was missing something in the uses area. Something in regards to chart. I tried copying and pasting all of the uses from my main unit but even with the whole list of uses, it is still undeclared so I thought it might have something to do with the type section.

Code: Select all

unit data_plotting;
interface

uses
  SysUtils, declarations, TeEngine;

function dataplotting: Variant;

implementation

uses
  headunit;

var
  I: SmallInt;
//..............................................................................
//	DATA PLOTTING FUNCTION REV 1.00/ 26/07/07
//..............................................................................
function dataplotting: Variant;
begin
  while not Eof(XFile) do //keep looping until the end of XFile
        begin
          Readln(XFile, x); //read line from file to x
          Readln(YFile, y1, y2, y3, y4, y5); 
          Chart3.Series[1].AddXY((x*xfreqmulti), (y1 * CalMulti), '', clTeeColor);
          Chart3.Series[2].AddXY((x*xfreqmulti), (((y4 * CalMulti) / 6) + MaxYValue + 4), '', clTeeColor);          
          Chart3.Series[3].AddXY((x*xfreqmulti), (((y2 * CalMulti) / 6) + MaxYValue + 7), '', clTeeColor);
          Chart3.Series[4].AddXY((x*xfreqmulti), (((y5 * CalMulti) / 6) + MaxYValue + 10), '', clTeeColor);
          Chart3.Series[5].AddXY((x*xfreqmulti), (y3 * CalMulti), '', clTeeColor); //plot transformer coil voltage
          QuickLoadBuffX[J]:= (x*xfreqmulti);
          QuickLoadBuffY[J]:= (y1 * CalMulti);          
          BluePoleBuffY[J]:= y5;
          RedPoleBuffY[J]:= y4;
          WhitePoleBuffY[J]:= y2;
          Inc (J); //increasing J by 1
        end;
end;
Last edited by myghetto on Thu Jul 26, 2007 11:53 pm, edited 1 time in total.

djsox
Newbie
Newbie
Posts: 8
Joined: Thu Jun 21, 2007 12:00 am

Post by djsox » Thu Jul 26, 2007 11:52 pm

Have you tried prefixing the Chart3 with it's forms name? i.e. (FormName).Chart3.series etc.

Where (FormName) is the name of the form containing Chart3.

It looks like in your code it might be called Form1, So it would read:
Form1.Chart3.Series... etc.

Of course you still need the unit containing Form1 in the uses clause.

Dan

myghetto
Newbie
Newbie
Posts: 27
Joined: Thu Oct 05, 2006 12:00 am

Post by myghetto » Thu Jul 26, 2007 11:57 pm

Hi Dan,

YOU ARE BRILLIANT. That is what I have been looking for. This has solved all the problems I am currently having. Thank you.

David

djsox
Newbie
Newbie
Posts: 8
Joined: Thu Jun 21, 2007 12:00 am

Post by djsox » Fri Jul 27, 2007 2:36 am

Glad I could help!

Dan

Post Reply