Page 1 of 1

TeeChartPro V7.12 Draw a graph

Posted: Mon May 04, 2009 11:37 am
by 9350489
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

Posted: Mon May 04, 2009 12:26 pm
by narcis
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;

Posted: Sat May 09, 2009 11:22 am
by 9350489
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

Posted: Mon May 11, 2009 10:57 am
by yeray
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.

Posted: Sat May 23, 2009 3:00 pm
by 9350489
Thank you very much Yeray for your help

Didier