Though really late, I can confirm that the solution is working fine. I still have to add some profiling code to measure it, though with added background it seems perceivably slower even on a recent PC (core i5 vpro). Are BGRA or other backends known to be faster?
thanks anyway for the help! R# 2014-09-04 1:08 GMT+02:00 Roberto P. <padovan...@gmail.com>: > Thank you very much. > I need a background image, therefore as soon as I am back at the office > I'll try your code. > Thank you again! > > R# > > > 2014-09-02 18:18 GMT+02:00 Werner Pamler <werner.pam...@freenet.de>: > >> It is not fully clear to me what you mean by "a chart with transparent >> background". Do you want to see the form underneath the chart? I fear this >> is not easily possible. Or do you want to have a background image in the >> chart? For the latter case this code is working fine with me: >> >> type >> TForm1 = class(TForm) >> Chart1: TChart; >> procedure Chart1BeforeDrawBackground(ASender: TChart; ACanvas: >> TCanvas; >> const ARect: TRect; var ADoDefaultDrawing: Boolean); >> procedure Chart1BeforeDrawBackWall(ASender: TChart; ACanvas: TCanvas; >> const ARect: TRect; var ADoDefaultDrawing: Boolean); >> procedure FormCreate(Sender: TObject); >> procedure FormDestroy(Sender: TObject); >> private >> { private declarations } >> FBackImage: TPicture; >> public >> { public declarations } >> end; >> .... >> procedure TForm1.Chart1BeforeDrawBackWall(ASender: TChart; ACanvas: >> TCanvas; >> const ARect: TRect; var ADoDefaultDrawing: Boolean); >> begin >> ADoDefaultDrawing := false; >> ACanvas.StretchDraw(ARect, FBackImage.Graphic); >> end; >> >> procedure TForm1.Chart1BeforeDrawBackground(ASender: TChart; ACanvas: >> TCanvas; >> const ARect: TRect; var ADoDefaultDrawing: Boolean); >> begin >> ACanvas.GradientFill(ARect, clSkyBlue, clWhite, gdVertical); >> ADoDefaultDrawing := false; >> end; >> >> procedure TForm1.FormCreate(Sender: TObject); >> begin >> FBackImage := TPicture.Create; >> FBackImage.LoadFromFile('C:\lazarus-svn\images\splash_logo.png'); >> // please adapt this path to your lazarus installation >> end; >> >> procedure TForm1.FormDestroy(Sender: TObject); >> begin >> FBackImage.Free; >> end; >> >> The basic idea is to assign a handler to the chart events >> OnBeforeDrawBackWall or OnBeforeDrawBackground and disable the default >> background painting by setting ADoDefaultDrawing to false. The first event >> replaces painting of the area enclosed by the chart's frame ("Back wall"), >> the other one replaces painting of the entire chart background. Above >> example paints the Lazarus splash-logo as BackWall and a gradient as >> background. >> >> Maybe I'll once write a tutorial on this topic... >> >> >> -- >> _______________________________________________ >> Lazarus mailing list >> Lazarus@lists.lazarus.freepascal.org >> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus >> > >
-- _______________________________________________ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus