Overlay complete chart object transparently onto control
Overlay complete chart object transparently onto control
Is there a way to configure the tChart object so the objects background is completely transparent when placed onto another window control? For example, If I wanted to place a pie chart onto a panel and I wanted the panels background to bleed through.
Hi Joey,
here I post one example code which does this (place a Chart over an image to make the back transparent).
here I post one example code which does this (place a Chart over an image to make the back transparent).
Code: Select all
unit Unit_Chart_Color_clNone;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, TeeProcs, TeEngine, Chart, StdCtrls, TeCanvas, Series,
jpeg;
type
TForm1 = class(TForm)
Chart1: TChart;
Series1: TLineSeries;
Image1: TImage;
CheckBox1: TCheckBox;
procedure FormCreate(Sender: TObject);
procedure Chart1BeforeDrawChart(Sender: TObject);
procedure Chart1AfterDraw(Sender: TObject);
procedure ScrollBar1Change(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
private
{ Private declarations }
Back : TBitmap;
Blend : TTeeBlend;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.Color:=clNone;
end;
type
TTeeCanvasAccess=class(TTeeCanvas3D);
procedure TForm1.Chart1BeforeDrawChart(Sender: TObject);
begin
if not Assigned(Back) then
begin
Back:=TBitmap.Create;
Back.Width:=Chart1.Width;
Back.Height:=Chart1.Height;
Back.Canvas.CopyRect(Chart1.ClientRect,Canvas,Chart1.BoundsRect);
end;
if Chart1.Color=clNone then
Chart1.Canvas.Draw(0,0,Back);
{ if ScrollBar1.Position>0 then
Blend:=Chart1.Canvas.BeginBlending(Chart1.,ScrollBar1.Position)
else
Blend:=nil;}
end;
procedure TForm1.Chart1AfterDraw(Sender: TObject);
begin
{ if Assigned(Blend) then
Chart1.Canvas.EndBlending(Blend);}
end;
procedure TForm1.ScrollBar1Change(Sender: TObject);
begin
Chart1.Invalidate;
end;
procedure TForm1.CheckBox1Click(Sender: TObject);
begin
if CheckBox1.Checked then
Chart1.Color:=clDefault
else
Chart1.Color:=clNone;
end;
end.
Pep Jorge
http://support.steema.com
http://support.steema.com