custom drawing disappears after a few milliseconds

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
digdagdigedag
Newbie
Newbie
Posts: 4
Joined: Tue Aug 04, 2009 12:00 am
Contact:

custom drawing disappears after a few milliseconds

Post by digdagdigedag » Tue Sep 01, 2009 4:23 pm

just after completing the a graph by setting the different values of a TBar3DSeries i want to draw a horizontal line as follows.

MyTeeChart->Canvas->MoveTo(0,MyTeeChart->LeftAxis->CalcYPosValue(0));
MyTeeChart->Canvas->LineTo(500,MyTeeChart->LeftAxis->CalcYPosValue(0));

unfortunately, the line dissapears immediately after a few milliseconds. does anybody know why ????

when placing the lines into an event like OnBeforeDrawSeries or OnAfterDraw the line stays but i can't use them for the following reasons:
beforedraw: at this point i do not yet know the position of the YPosValue(0) so i need to know after the series is complete
afterdraw: i would like to have the line behind the seriesbars, so afterdraw would be too late

thanks for some hints
uwe

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

Re: custom drawing disappears after a few milliseconds

Post by Yeray » Wed Sep 02, 2009 7:41 am

Hi uwe,

OnBeforeDrawSeries seems to work fine for me here. Could you please try the following example and see if it works as you wish?

Code: Select all

var bar1: TBar3DSeries;

procedure TForm1.Chart1BeforeDrawSeries(Sender: TObject);
begin
  with Chart1.Canvas do
  begin
    Pen.Color := clRed;
    MoveTo(Chart1.Axes.Bottom.IStartPos,Chart1.Axes.Left.CalcYPosValue(0));
    LineTo(Chart1.Axes.Bottom.IEndPos,Chart1.Axes.Left.CalcYPosValue(0));
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  bar1 := TBar3DSeries.create(self);
  Chart1.AddSeries(bar1);

  bar1.AddBar(0, 50, -10);
  bar1.AddBar(1, -50, 20);
  bar1.AddBar(2, 70, -5);
  bar1.AddBar(3, 10, 0);
  bar1.AddBar(4, -20, 0);
end;
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

digdagdigedag
Newbie
Newbie
Posts: 4
Joined: Tue Aug 04, 2009 12:00 am
Contact:

Re: custom drawing disappears after a few milliseconds

Post by digdagdigedag » Wed Sep 02, 2009 8:23 pm

i tried your example and also applied it to my own application. everything works fine now !!!
thanks a lot
uwe

Post Reply