TeeChartPro V7.12 Draw a graph

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Clara Genermont
Newbie
Newbie
Posts: 42
Joined: Mon Jun 11, 2007 12:00 am
Contact:

TeeChartPro V7.12 Draw a graph

Post by Clara Genermont » Mon May 04, 2009 11:37 am

Hi Narcis,

I have a set of points (x, y) which I wish to make the graph.
everything works well and it's appears :

// test.csv
q;ha
0,5;25,3
0,55;24,7
0,6;24
0,65;23,5
0,7;23
0,8;22,2
0,9;21,4
1;20,8
1,1;20,2
1,2;19,7
1,3;19,2
1,4;18,8
1,6;18,1
1,8;17,5
2;17
2,25;16,5
2,5;15,8
2,75;15,4
3;15

here is the code :

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
begin
  with SeriesTextSource1 do
  begin
    Fields.Clear;
    AddField('q', 1);
    AddField('ha', 2);
    HeaderLines := 1;
    FieldSeparator := ';';
    DecimalSeparator := ',';
    FileName := 'test.csv';
    Series := Series1;
    Chart1.LeftAxis.Title.Visible := true;
    Chart1.BottomAxis.Title.Visible := true;
    Active := True;
  end;
end;
BUT, strangely, it is impossible to verify the pairs of values on the curve
example: q = 2 should give ha = 17 and
q = 3 should give ha = 15

?
Can you help me

thank you

Didier

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

Post by Narcís » Mon May 04, 2009 12:26 pm

Hi Didier,

That's because you should add field "X" instead of "q". This works fine:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var tmp: Integer;
begin
  //Series1.XValues.Order:=loDescending;

  with SeriesTextSource1 do
  begin
    Fields.Clear;
    AddField('X', 1);
    AddField('ha', 2);
    HeaderLines := 1;
    FieldSeparator := ';';
    DecimalSeparator := ',';
    FileName := 'c:\temp\test.csv';
    Series := Series1;
    Chart1.LeftAxis.Title.Visible := true;
    Chart1.BottomAxis.Title.Visible := true;
    Active := True;
  end;

  tmp:=Series1.XValues.Locate(2);
  Chart1.Title.Text[0]:=FloatToStr(Series1.YValues[tmp]);
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

Clara Genermont
Newbie
Newbie
Posts: 42
Joined: Mon Jun 11, 2007 12:00 am
Contact:

Post by Clara Genermont » Sat May 09, 2009 11:22 am

Hi Narcis,

thank you for your attention
but

Why is it necessary to specify 'X' instead of 'q' as the file column. Csv is defined by 1 or 2?

Thank you for your help

Didier

Yeray
Site Admin
Site Admin
Posts: 9534
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Mon May 11, 2009 10:57 am

Hi Didier

The series have Y defined as mandatory. That means that Y values are a must to have while the X are optional. So, adding only Y values, the X values are set automatically. That will probably be the reason why if you don't call your X values as X, the series gets confused.

I hope I'm understandable.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Clara Genermont
Newbie
Newbie
Posts: 42
Joined: Mon Jun 11, 2007 12:00 am
Contact:

Post by Clara Genermont » Sat May 23, 2009 3:00 pm

Thank you very much Yeray for your help

Didier

Post Reply