I need the legend to be to the right of the chart, but I want it to be aligned to the bottom rather than the top of the chart.
How can I do that?
Thanks,
Ed Dressel
Legend Position
-
- Advanced
- Posts: 228
- Joined: Tue Aug 28, 2007 12:00 am
- Location: Oregon, USA
Re: Legend Position
Hi Ed,
You could place your legend manually like following:
You could place your legend manually like following:
Code: Select all
uses series;
procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
for i:=0 to 4 do
with Chart1.AddSeries(TBarSeries) do FillSampleValues;
Chart1.Draw;
Chart1.MarginUnits:=muPixels;
Chart1.MarginRight:=100;
Chart1.Legend.CustomPosition:=true;
Chart1.Legend.Left:=Chart1.Width-Chart1.Legend.Width-10;
Chart1.Legend.Top:=Chart1.Axes.Bottom.PosAxis-Chart1.Legend.Height-10;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Advanced
- Posts: 228
- Joined: Tue Aug 28, 2007 12:00 am
- Location: Oregon, USA
Re: Legend Position
This works until I resize the chart--the legend stays in the same location.
I tried some before/after draw events, and they did not work.
Any suggestions?
Ed Dressel
I tried some before/after draw events, and they did not work.
Any suggestions?
Ed Dressel
Re: Legend Position
Hello Ed,
I have done next example using OnAfterDraw event and works fine for me.
Could you please, tell us if previous code works as you want? If code doesn't work fine for you please, explain us which is the exactly problem.
I hope will helps.
Thanks,
I have done next example using OnAfterDraw event and works fine for me.
Code: Select all
procedure TForm1.Chart1AfterDraw(Sender: TObject);
begin
Chart1.Legend.CustomPosition:=true;
Chart1.Legend.Left:=Chart1.Width-Chart1.Legend.Width-10;
Chart1.Legend.Top:=Chart1.Axes.Bottom.PosAxis-Chart1.Legend.Height-10;
end;
procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
for i:=0 to 4 do
with Chart1.AddSeries(TBarSeries) do FillSampleValues;
Chart1.Align:= alClient;
Chart1.MarginUnits:=muPixels;
Chart1.MarginRight:=100;
Chart1.Draw;
end;
I hope will helps.
Thanks,
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Advanced
- Posts: 228
- Joined: Tue Aug 28, 2007 12:00 am
- Location: Oregon, USA
Re: Legend Position
The attached demo (using 8.06) draws the legend in the wrong location the first time. After a redraw, it works fine.
Ed D
Ed D
- Attachments
-
- Legend Location 2.zip
- (2.99 KiB) Downloaded 514 times
Re: Legend Position
Hello TestAlways,
If you want that legend location would be correct the first time, you need added Chart1.Draw twice in from create as do in next lines of code:
I also inform you, there is recent version of TeeChartVCL(8.07) you can download it here.
I hope will helps.
Thanks,
If you want that legend location would be correct the first time, you need added Chart1.Draw twice in from create as do in next lines of code:
Code: Select all
constructor TForm2.Create(aOnwer: TComponent);
begin
inherited;
Series1.FillSampleValues(20);
Series2.FillSampleValues(20);
Series2.Title := 'this is a long description';
Chart1.MarginUnits:=muPixels;
Chart1.Draw;
Chart1.Draw;
// Chart1.MarginRight:=100;
end;
I hope will helps.
Thanks,
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |