Forum > TAChart

Newbie TAchart Problem

(1/2) > >>

acp693:
Hi I'm new to Pascal and Lazarus. I already built a calculator with Lazarus to try out the Pascal language and am enjoying it a lot.

Last night I tried charts. I placed a button and a TChart on a form and copied the code from this page on the wiki
http://wiki.lazarus.freepascal.org/TAChart/de , but I get compilation errors.  Any help would be gratefully received.

I'm using Lazarus IDE v0.9.26.2-0 , FPC version 2.2.2 ,  i386-linux-gtk 2 (beta)
on Debian Lenny 5.0.

Albert

unit1.pas(34,17) Error: Identifier not found "TTASerie"
unit1.pas(34,17) Error: Error in type definition
unit1.pas(39,16) Error: Identifier not found "TTASerie"
unit1.pas(40,22) Error: Incompatible type for arg no. 1: Got "<erroneous type>", expected "TComponent"
tagraph.pas(1273,18) Hint: Found declaration: TChart.AddSerie(TComponent)
unit1.pas(41,7) Error: Illegal qualifier
unit1.pas(42,7) Error: Illegal qualifier
unit1.pas(43,7) Error: Illegal qualifier
unit1.pas(45,10) Error: Illegal qualifier
unit1.pas(54) Fatal: There were 8 errors compiling module, stopping

This is my code:

--- Code: ---unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
  TAGraph, StdCtrls, TACHartUtils;

type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    Chart1: TChart;
    procedure Button1Click(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form1: TForm1;

implementation

{ TForm1 }

procedure TForm1.Button1Click(Sender: TObject);
var
  Serie:TTASerie;
  i:Integer;


begin
Serie:=TTASerie.Create(Chart1);
Chart1.AddSerie(Serie);
Serie.ShowLines:=True;
Serie.ShowPoints:=False;
Serie.Title:='Sinus';
for i:=-500 to 499 do
   Serie.AddXY(i/10,Sin(i/10)*10,clBlack);

end;

initialization
  {$I unit1.lrs}

end.
                                                                       
--- End code ---

Blaazen:
I think "Chart1: TChart;" would be "Chart1: TTAChart;",
but I can't test it now because I haven't my notebook with Lazarus here now.

Vincent Snijders:
The German wiki page is outdated, the English wiki page is up to date.

Instead of having this code, it refers to the demos that are distributed with the component.

alanphys:
Add unit TASeries to your uses

Cheers

Alanphys

acp693:
Thanks, I added TASeries to the uses but that doesn't make any difference, Nor does the suggestion by Blaazen.

I'm quite confused by the chart system in Lazarus. I see references to TChart and TAChart, but only a widget for TChart, Does TAChart use the TChart widget?

last night I also looked at the demo of TAChart found in Components/TAChart. I don't understand How this demo works, The demo unit  itself is called TAGraph, is this the same TAGraph that gets added to uses when I place a TChart on a form?  After compilation there appears a gui with buttons checkboxes etc.
However, in unit TAGraph I can't find any code that builds this gui?  Any thoughts?

regards

Albert

Navigation

[0] Message Index

[#] Next page

Go to full version