Bottom position legent with single column how?

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Raju S Nair
Newbie
Newbie
Posts: 10
Joined: Wed Sep 28, 2005 4:00 am

Bottom position legent with single column how?

Post by Raju S Nair » Fri Mar 30, 2007 8:12 am

Hi,
I selected Legend Style is series name and its position as bottom but when i selected multiple series the series name displaying in a single line how can i convert into two line that menas I need only one column in legend regardless of positon selection.

Thanks in advance
Raju S Nair

Pep
Site Admin
Site Admin
Posts: 3299
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Wed Apr 04, 2007 6:50 am

Hi,

there's not a way to do this automatically. This feature is already added on our wish list to be considered for further releases.
With actual version there're are several ways to accomplish it :
1) Having the chart legend alignment to Right (as default), set it to custom position and then change left and top to desired position.
2) Draw the legend on the canvas manually, using the canvas techniques.
3) Use a ChartListBox component to display the legend items, you only must place it over the Chart (at desired pos), assign it to the Chart, and then change its properties (like hide Series Icon, back color, border, etc..) and finally via code do the following :
ChartListBox1.SelectedSeries:=nil;
to have no one series selected.

Raju S Nair
Newbie
Newbie
Posts: 10
Joined: Wed Sep 28, 2005 4:00 am

Bottom position legend with single column how?

Post by Raju S Nair » Wed Apr 04, 2007 7:55 am

Yes I have tried with Right alignment and custom position but in that case if it crosses bottom axis legend is disappearing so that method is not feasible for me.
I am trying to accomplish the feature from TeeChart itself and try to avoid extra coding. So if you rectify disappearing of the legend then that is good for me

Pep
Site Admin
Site Admin
Posts: 3299
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Wed Apr 04, 2007 5:04 pm

Hi,

in that case the best way I can think would be to do the following :

Code: Select all


  private
    { Private declarations }
    tmpRect:Trect;
    Buffer : TBitmap;

uses TeCanvas;

procedure TForm1.FormCreate(Sender: TObject);
begin
     Chart1.MarginBottom:=30;
     Chart1.Draw;
     Chart1.Legend.Hide;
end;

procedure TForm1.Chart1AfterDraw(Sender: TObject);
begin
  if chart1.Legend.Visible=true then
  begin
    Buffer:=TBitmap.Create;
    Buffer.Width:=Chart1.Legend.Width;
    Buffer.Height:=Chart1.Legend.Height;
    Buffer.Canvas.CopyRect(TeeRect(0,0,Chart1.Legend.Width,Chart1.Legend.Height),Chart1.Canvas.ReferenceCanvas,tmpRect);
  end;
  Chart1.Canvas.Draw(Chart1.Canvas.Bounds.Right div 2,Chart1.Canvas.Bounds.Bottom-Chart1.Legend.Height,buffer);
end;

Post Reply