Page 1 of 1

Declaring Chart.Series as a variable on another unit

Posted: Thu Jul 26, 2007 1:03 am
by 9347662
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

Posted: Thu Jul 26, 2007 8:41 am
by Pep
Hi David,

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

Posted: Thu Jul 26, 2007 11:22 pm
by 9347662
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?

Posted: Thu Jul 26, 2007 11:45 pm
by 9347662
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;

Posted: Thu Jul 26, 2007 11:52 pm
by 10545618
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

Posted: Thu Jul 26, 2007 11:57 pm
by 9347662
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

Posted: Fri Jul 27, 2007 2:36 am
by 10545618
Glad I could help!

Dan