Page 1 of 1

Chart transparency

Posted: Tue Jun 19, 2012 8:13 pm
by 9347097
Hello, I have both Pro 7.08 (in Delphi 2006) and Standard 2010.01.20814 (in Delphi XE). I am looking to get a white interior (the area within the axes) and transparent outside of this to the edges of the chart. The white interior is fine (BackWall.Color=clWhite and Transparent=False) but I don't see any option for the outer transparency. I've tried Chart.Color=clNone but this just results in white.

(Note: I am trying to duplicate the appearance of an Excel chart. This is done quite easily with ChartArea.Fill=NoFill and PlotArea.Fill=Solid.)

Is this possible? Do I need to get the current version (2012)?

TIA, Jim

Re: Chart transparency

Posted: Fri Jun 22, 2012 2:00 pm
by 10050769
Hello Jim,

I have made a simple code that I can help to achieve as you want:

Code: Select all

Uses Series;
procedure TForm3.FormCreate(Sender: TObject);
var Series1:TLineSeries;
begin
  Chart1.Walls.Left.Visible := false;
  Chart1.Walls.Bottom.Visible:=false;
  Chart1.Walls.Back.Color:= clWhite;
  Chart1.Walls.Back.Visible:=false;
  Chart1.Gradient.Visible:=false;
  Chart1.Color := clWhite;
  Series1 := TLineSeries.Create(self);
  Chart1.AddSeries(Series1);

end;
Can you tell us if next code works as you expecte?
Thanks,

Re: Chart transparency

Posted: Fri Jun 22, 2012 2:24 pm
by 9347097
Sandra, thanks for the reply. Sorry, no, this produces a completely white chart (using Standard 2010.01.20814) I don't see anything in the code below that indicates transparency for the outer area. (I DO see a Transparent property for the BackWall that does let the Chart1.Color show through.) Note that I'm only doing a 2D chart, so the walls other than Back are N/A.

Surely there must be a way to do this. Like "Chart1.Transparent := True;"? Or "Chart1.ParentBackground := True;"? (like TPanel)

Jim

Re: Chart transparency

Posted: Tue Jun 26, 2012 4:00 pm
by 10050769
Hello Jim,

Ok. I suggest you taking a look in this thread where Narcís explains as you achieve the panel to be transparent.

Thanks,

Re: Chart transparency

Posted: Tue Jun 26, 2012 6:30 pm
by 9347097
The link you gave is to a thread title "Anchors not published" (?)

However, if you're referring to this:

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);

Then yes, it does work (with alterations for when the parent is a TPanel, not a Form).

Still, I'm very surprised this is not a built-in option!

Re: Chart transparency

Posted: Wed Jun 27, 2012 7:48 am
by 10050769
Hello Jim,

Sorry I have been wrong with link. The correct thread is this.
Still, I'm very surprised this is not a built-in option!
if you take a look in the link you will find the problem is caused for the panel as explained Narcís

Thanks,