Page 1 of 1

AddXY - Adding series during runtime

Posted: Tue Aug 29, 2006 5:24 pm
by 9237792
Hello,

I've just taken over some code from someone who left the company. I'm fairly new to using the TTeeChart components. I have a problem where a flat line continuously gets draw along 0 on the vertical axis. The code is fairly straightforward...

Code: Select all

acurve := TLineSeries.Create(Chart1);

*for loop*
acurve.AddXY(xvalue, yvalue);
*end loop*

  with acurve do
  begin
    VertAxis := aLeftAxis;
    HorizAxis := aBottomAxis;
    ParentChart := Chart1;
    LinePen.Width := 3;
  end;

  with acurve.Pointer do
  begin
    Visible := true;
    HorizSize := 4;
    VertSize := 4;
    Style := psRectangle
  end;
the x axis appears to be plotted correctly but the y axis is always flat. The *for loop* above is fine, i just wanted to reduce the code in this post. it can go through the loop any number of times, it depends on how many points there are to plot. I've traced it and every point is valid. Why does it always appear flat.

Thanks

Posted: Wed Aug 30, 2006 5:39 am
by Marjan
Hi.

Which TeeChart and Delphi version are you using ? Perhaps the problem is left axis automatic scaling was accidentally disabled at design time. Try reseting it with the following code:

Code: Select all

acurve.GetVertAxis.Automatic := true;
Also, check if all yvalues are not the same. Another thing to check is if acurve series is actually "connected" to chart i.e. if it's ParentChart property is set to Chart1:

Code: Select all

acurve := TLineSeries.Create(Chart1);
acurve.ParentChart := Chart1;

Posted: Wed Aug 30, 2006 8:03 pm
by 9237792
Hi Marjan,

Thanks. The first suggestion was the problem.

Cheers