<div dir="ltr">Thank you very much.<div>I need a background image, therefore as soon as I am back at the office I'll try your code.</div><div>Thank you again!<br></div><div><br></div><div>R#</div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">2014-09-02 18:18 GMT+02:00 Werner Pamler <span dir="ltr"><<a href="mailto:werner.pamler@freenet.de" target="_blank">werner.pamler@freenet.de</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
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:<br>
<br>
type<br>
TForm1 = class(TForm)<br>
Chart1: TChart;<br>
procedure Chart1BeforeDrawBackground(<u></u>ASender: TChart; ACanvas: TCanvas;<br>
const ARect: TRect; var ADoDefaultDrawing: Boolean);<br>
procedure Chart1BeforeDrawBackWall(<u></u>ASender: TChart; ACanvas: TCanvas;<br>
const ARect: TRect; var ADoDefaultDrawing: Boolean);<br>
procedure FormCreate(Sender: TObject);<br>
procedure FormDestroy(Sender: TObject);<br>
private<br>
{ private declarations }<br>
FBackImage: TPicture;<br>
public<br>
{ public declarations }<br>
end;<br>
....<br>
procedure TForm1.<u></u>Chart1BeforeDrawBackWall(<u></u>ASender: TChart; ACanvas: TCanvas;<br>
const ARect: TRect; var ADoDefaultDrawing: Boolean);<br>
begin<br>
ADoDefaultDrawing := false;<br>
ACanvas.StretchDraw(ARect, FBackImage.Graphic);<br>
end;<br>
<br>
procedure TForm1.<u></u>Chart1BeforeDrawBackground(<u></u>ASender: TChart; ACanvas: TCanvas;<br>
const ARect: TRect; var ADoDefaultDrawing: Boolean);<br>
begin<br>
ACanvas.GradientFill(ARect, clSkyBlue, clWhite, gdVertical);<br>
ADoDefaultDrawing := false;<br>
end;<br>
<br>
procedure TForm1.FormCreate(Sender: TObject);<br>
begin<br>
FBackImage := TPicture.Create;<br>
FBackImage.LoadFromFile('C:\<u></u>lazarus-svn\images\splash_<u></u>logo.png');<br>
// please adapt this path to your lazarus installation<br>
end;<br>
<br>
procedure TForm1.FormDestroy(Sender: TObject);<br>
begin<br>
FBackImage.Free;<br>
end;<br>
<br>
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.<br>
<br>
Maybe I'll once write a tutorial on this topic...<br>
<br>
<br>
--<br>
______________________________<u></u>_________________<br>
Lazarus mailing list<br>
<a href="mailto:Lazarus@lists.lazarus.freepascal.org" target="_blank">Lazarus@lists.lazarus.<u></u>freepascal.org</a><br>
<a href="http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus" target="_blank">http://lists.lazarus.<u></u>freepascal.org/mailman/<u></u>listinfo/lazarus</a><br>
</blockquote></div><br></div>