Showing Series Label Below Each Pie Chart and Mark Position
-
- Newbie
- Posts: 7
- Joined: Wed Jul 11, 2007 12:00 am
Showing Series Label Below Each Pie Chart and Mark Position
I am using D7 and Tee8.
I have 3 pie series in a single TChart which are displayed horz. I would like to have the series name below each one. Is this possible?
Also, I would like to have the pie marks show up on top of the pie slices. The reason for this is because when marks are displayed, the chart gets shrunken to a point of not being visible. I've tried playing with the mark positions, but it's not going well. Any ideas?
I posted a similar question on the newsgroup, but I noticed that this forum exists.
I have 3 pie series in a single TChart which are displayed horz. I would like to have the series name below each one. Is this possible?
Also, I would like to have the pie marks show up on top of the pie slices. The reason for this is because when marks are displayed, the chart gets shrunken to a point of not being visible. I've tried playing with the mark positions, but it's not going well. Any ideas?
I posted a similar question on the newsgroup, but I noticed that this forum exists.
Hi, Isaac Alexander!
Try to change Series Marks Callout Distance and Length properties to negative like this
Seems produces desired effect.
For Legends see e.g. Multiple Legends Demo (Legend_Multi.pas) in Tee8New Demo
PS. Alexander is your name or surname?
Try to change Series Marks Callout Distance and Length properties to negative like this
Code: Select all
Marks.Callout.Distance = -11
Marks.Callout.Length = -9
For Legends see e.g. Multiple Legends Demo (Legend_Multi.pas) in Tee8New Demo
PS. Alexander is your name or surname?
Regards, Alexander
=================
TeeChart Pro v8.05, Delphi 5 & Turbo Delphi Professional for Win32., Delphi & C++Builder 2009
=================
TeeChart Pro v8.05, Delphi 5 & Turbo Delphi Professional for Win32., Delphi & C++Builder 2009
-
- Newbie
- Posts: 7
- Joined: Wed Jul 11, 2007 12:00 am
It helps with moving the mark labels on top of the pie slices, but the margins between each pie series are still huge. It changed a little with the above change. Is there a way to change the margin size that gets reserved for each series marks?9047589 wrote:Try to change Series Marks Callout Distance and Length properties to negative like thisSeems produces desired effect.Code: Select all
Marks.Callout.Distance = -11 Marks.Callout.Length = -9
That looks like it would work for legends for each series, but I only want the name of the series below each pie. Can it be done the the BeforeDrawValues event with the custom series drawing? If so, is there an example?For Legends see e.g. Multiple Legends Demo (Legend_Multi.pas) in Tee8New Demo
Alexander is my last name. Not sure how that got into the signature. I didnt have one set. I put one it.PS. Alexander is your name or surname?
Hi, Isaac!
?
Do you try to achieve an effect like this10046043 wrote:Is there a way to change the margin size that gets reserved for each series marks?
?
If you use D7, that was shipped with TeeChart Standard, look at Demos\Teechart\udraw.pas in your Delphi. And I recommend use AfterDraw* events.[/img]That looks like it would work for legends for each series, but I only want the name of the series below each pie. Can it be done the the BeforeDrawValues event with the custom series drawing? If so, is there an example?
Regards, Alexander
=================
TeeChart Pro v8.05, Delphi 5 & Turbo Delphi Professional for Win32., Delphi & C++Builder 2009
=================
TeeChart Pro v8.05, Delphi 5 & Turbo Delphi Professional for Win32., Delphi & C++Builder 2009
-
- Newbie
- Posts: 7
- Joined: Wed Jul 11, 2007 12:00 am
Not really, I'm looking for something more like this.
Current display:
What I want to display:
That example doesn't seem to show how to dump additional text on the screen.If you use D7, that was shipped with TeeChart Standard, look at Demos\Teechart\udraw.pas in your Delphi. And I recommend use AfterDraw* events.
Hi Isaac,
If the Pie Series title is not going to change during execution I suggest you to use annotation tools or labels.
Otherwise, you should use the OnAfterDraw event suggested above.
If the Pie Series title is not going to change during execution I suggest you to use annotation tools or labels.
Otherwise, you should use the OnAfterDraw event suggested above.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Hi.
I think he used OnBeforeDrawValues event (as demonstrated in TeeChart "Multiple Pies" demo) with a little twist:
As for series title below each pie, you can draw required text in the Chart OnAfterDraw values. Something like this:
And finally, to reduce the margins between pies, try setting each pie CustomXRadius and CustomYRadius properties to meaningful values. In your case, something like this:
BTW, new TeeChart v8 VCL already automatically arranges multiple pie series (in multiple rows/cols).
I think he used OnBeforeDrawValues event (as demonstrated in TeeChart "Multiple Pies" demo) with a little twist:
Code: Select all
procedure TPieMultiple.Series1BeforeDrawValues(Sender: TObject);
begin
Chart1.ChartRect:=Rect(10,10,Chart1.Width div 3, Chart1.Height - 10);
end;
procedure TPieMultiple.Series2BeforeDrawValues(Sender: TObject);
begin
Chart1.ChartRect:=Rect(Chart1.Width div 3, 10, 2*(Chart1.Width div 3),Chart1.Height-10);
end;
procedure TPieMultiple.Series3BeforeDrawValues(Sender: TObject);
begin
Chart1.ChartRect:=Rect(2*(Chart1.Width div 3), 10,Chart1.Width, Chart1.Height-10);
end;
Code: Select all
procedure TForm1.Chart1AfterDraw(Sender: TObject);
var x,y,w: Integer;
st: String;
i,tw: Integer;
begin
With Chart1, Chart1.Canvas do
begin
y := Chart1.ChartRect.Bottom-10;
Font.Style := [fsBold];
// assume all series are pies in-a-row
w := Chart1.Width div Chart1.SeriesList.Count;
for i := 0 to Chart1.SeriesList.Count -1 do
begin
tw := TextWidth(Chart1.Series[i].Title);
x := i*w + (w-tw) div 2;
TextOut(x,y,Chart1.Series[i].Title);
end;
end;
end;
Code: Select all
Series1.CustomXRadius := Chart1.Width div 3 -30;
Series1.CustomYRadius := Series1.CustomXRadius;
//...
Marjan Slatinek,
http://www.steema.com
http://www.steema.com
-
- Newbie
- Posts: 7
- Joined: Wed Jul 11, 2007 12:00 am
You are correct. I used the following code.I think he used OnBeforeDrawValues event (as demonstrated in TeeChart "Multiple Pies" demo) with a little twist
Code: Select all
procedure TMyChart.CustomBeforeDrawValues(Sender: TObject);
var
TempIndex, TempWidth : integer;
begin
TempIndex := SeriesList.IndexOf(Sender);
TempWidth := Width div SeriesList.Count;
ChartRect := Rect(TempWidth * TempIndex, 0, TempWidth * (TempIndex + 1), Height);
end;
As for series title below each pie, you can draw required text in the Chart OnAfterDraw values. Something like this:
Code: Select all
procedure TMyChart.CustomAfterDraw(Sender: TObject);
var
i, TempTextWidth, TempX, TempY, TempWidth: Integer;
begin
with Canvas do
begin
TempY := ChartRect.Bottom - 15;
Font.Style := [fsBold];
// assume all series are pies in-a-row
TempWidth := Width div SeriesList.Count;
for i := 0 to SeriesList.Count -1 do
begin
if (Series[i] is TCircledSeries) then
begin
TempTextWidth := TextWidth(Series[i].Title);
TempX := (i * TempWidth) + (TempWidth - TempTextWidth) div 2;
TextOut(TempX, TempY, Series[i].Title);
end;
end;
end;
end;
It's working, sort of. I would like the pies to increase in size as the chart form is resized. If I set the Custom Radiuses once, then the pies don't resize. Also, the space between pies shrink, but the space before the first pie does not. The labels for the pies move perfectly, but the pies do not.And finally, to reduce the margins between pies, try setting each pie CustomXRadius and CustomYRadius properties to meaningful values. In your case, something like this:
Here's the code:
Code: Select all
procedure TMyChart.ResizeMultipleCircledSeries;
var
i, TempSize : integer;
begin
if (SeriesList.Count > 1) then
begin
for i := 0 to (SeriesList.Count - 1) do
begin
if (Series[i] is TCircledSeries) then
begin
with (Series[i] as TCircledSeries) do
begin
TempSize := (Self.Width div SeriesList.Count) - 30;
CustomXRadius := TempSize;
CustomYRadius := CustomXRadius;
end;
end;
end;
end;
end;
Here is the larger view (795 x 138)
If I put the code in the Resize event of the chart, I can't seem to get the calc working correctly. The pies keep growing at a faster rate than the form which cause them to grow outside the margins of the chart.
I saw this. Doesn't it automatically make them two deep? I would like to control the number of pies per row.BTW, new TeeChart v8 VCL already automatically arranges multiple pie series (in multiple rows/cols).
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Isaac,
Maybe you could solve this much easily. You could align the chart to the form:
Or use something like the code below in the form's OnResize event:
Maybe you could solve this much easily. You could align the chart to the form:
Code: Select all
Chart1.Align:=alClient;
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
begin
tmpWidth:=Width;
tmpHeight:=Height;
end;
procedure TForm1.FormResize(Sender: TObject);
begin
Chart1.Width:=Chart1.Width+(Width-tmpWidth);
Chart1.Height:=Chart1.Height+(Height-tmpHeight);
tmpWidth:=Width;
tmpHeight:=Height;
end;
Best Regards,
Narcís Calvet / 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 |
-
- Newbie
- Posts: 7
- Joined: Wed Jul 11, 2007 12:00 am
I wish it were that simple. I want to show pies in a different orientation than the default which causes me to set the series Rects myself. The chart is aligned to the form/panel. If the panel could not be resized, I would be done. The problem is that with the resizing. I can't get it to scale properly. The pies grow faster than the form/panel. Please see my earlier comments. Thanks.Maybe you could solve this much easily. You could align the chart to the form
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Isaac,
Using what Marjan suggested and aligning the chart to alClient automatically resizes the pies when re-dimensioning the form. Have you tried using something like this?
If the problem persists, could you please send us a simple example project we can run "as-is" to reproduce the problem here?
You can either post your files at news://www.steema.net/steema.public.attachments or at our upload page.
Thanks in advance.
Using what Marjan suggested and aligning the chart to alClient automatically resizes the pies when re-dimensioning the form. Have you tried using something like this?
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.Align:=alClient;
Series1.MultiPie:=mpDisabled;
Series2.MultiPie:=mpDisabled;
Series3.MultiPie:=mpDisabled;
Series1.Circled:=true;
Series2.Circled:=true;
Series3.Circled:=true;
Series1.FillSampleValues();
Series2.FillSampleValues();
Series3.FillSampleValues();
end;
procedure TForm1.Series1BeforeDrawValues(Sender: TObject);
begin
Chart1.ChartRect:=Rect(10,10,Chart1.Width div 3, Chart1.Height);
end;
procedure TForm1.Series2BeforeDrawValues(Sender: TObject);
begin
Chart1.ChartRect:=Rect(Chart1.Width div 3,10, (Chart1.Width div 3)*2, Chart1.Height);
end;
procedure TForm1.Series3BeforeDrawValues(Sender: TObject);
begin
Chart1.ChartRect:=Rect((Chart1.Width div 3)*2, 10, Chart1.Width, Chart1.Height);
end;
You can either post your files at news://www.steema.net/steema.public.attachments or at our upload page.
Thanks in advance.
Best Regards,
Narcís Calvet / 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 |