Page 1 of 1

custom drawing disappears after a few milliseconds

Posted: Tue Sep 01, 2009 4:23 pm
by 10054052
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

Re: custom drawing disappears after a few milliseconds

Posted: Wed Sep 02, 2009 7:41 am
by yeray
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;

Re: custom drawing disappears after a few milliseconds

Posted: Wed Sep 02, 2009 8:23 pm
by 10054052
i tried your example and also applied it to my own application. everything works fine now !!!
thanks a lot
uwe