Page 1 of 2
Pie Chart Legend bug or my missing call?
Posted: Mon Jun 16, 2025 7:26 pm
by 16493447
I am using a Pie Chart and when I send some data to it the first time, it is great. It looks like:

- Chart1.png (34.22 KiB) Viewed 3524 times
However, when I try to limit the data, the legend entries all stay. I call the Clear function on the series, then run the data again with fewer entries and get:

- Chart2.png (29 KiB) Viewed 3524 times
Thank you,
John
Re: Pie Chart Legend bug or my missing call?
Posted: Tue Jun 17, 2025 2:49 pm
by yeray
Hello John,
I've seen the fix for
#1210 in TeeChart v2025.44 breaks this.
We are revising it.
Re: Pie Chart Legend bug or my missing call?
Posted: Tue Jun 17, 2025 5:54 pm
by 16493447
Thanks Yerah.
I think I have identified another small bug. Using PrintPartialCanvas, the chart titles don't seem to adjust to the given rectangle:

- PrintPartialCanvas.png (70.44 KiB) Viewed 3349 times
I was going to go tinkering around in the code, but figured I would point it out anyway.
Thanks,
John
Re: Pie Chart Legend bug or my missing call?
Posted: Tue Jun 17, 2025 5:57 pm
by 16493447
Plus, what does PrintProportional do? It says it is on by default, but the charts seem to stretch if I don't set the right aspect ratio. The circular gauges ignore the Circled property.
Thanks again...
Re: Pie Chart Legend bug or my missing call?
Posted: Tue Jun 17, 2025 6:36 pm
by 16493447
I figured maybe I could get around it by drawing to a Bitmap, then painting that to the printer. I got this:

- Bitmap.png (28.66 KiB) Viewed 3337 times
John
Re: Pie Chart Legend bug or my missing call?
Posted: Tue Jun 17, 2025 8:12 pm
by yeray
Hello John,
Yeray wrote: ↑Tue Jun 17, 2025 2:49 pm
I've seen the fix for
#1210 in TeeChart v2025.44 breaks this.
We are revising it.
I came up with this fix:
Code: Select all
--- a/Chart.pas
+++ b/Chart.pas
@@ -418,6 +418,7 @@ type
ILegend : TCustomChartLegend;
+ procedure FontChanged(Sender: TObject);
function GetFont:TTeeFont;
procedure SetAlign(const Value:TCanvasTextAlign);
procedure SetCustom(SetPos:Boolean);
@@ -5400,6 +5401,11 @@ begin
result:=Assigned(FFont);
end;
+procedure TLegendItem.FontChanged(Sender: TObject);
+begin
+ SetCustom(False);
+end;
+
function TLegendItem.GetFont:TTeeFont;
var Old : Boolean;
begin
@@ -5417,6 +5423,7 @@ begin
else
FFont:=TTeeFont.Create(nil);
+ FFont.OnChange:=FontChanged;
result:=FFont;
end;
@@ -5516,11 +5523,6 @@ begin
result:=TLegendItem.Create;
result.ILegend:=ILegend;
- if ILegend.InternalLegendStyle=lsAuto then
- ILegend.CalcLegendStyle;
-
- result.Text:=ILegend.FormattedLegend(Index);
-
inherited Items[Index]:=result;
end;
end;
Re: Pie Chart Legend bug or my missing call?
Posted: Wed Jun 18, 2025 2:51 am
by 16493447
Hello, I am getting a compile error with those changes:

- Compile.png (55.19 KiB) Viewed 3270 times
John
Re: Pie Chart Legend bug or my missing call?
Posted: Wed Jun 18, 2025 8:29 am
by yeray
Hello John,
Sorry. This is the fix for that error:
Code: Select all
--- a/Chart.pas
+++ b/Chart.pas
@@ -5523,6 +5523,9 @@ end;
procedure TLegendItem.FontChanged(Sender: TObject);
begin
SetCustom(False);
+
+ if Assigned(ILegend) then
+ ILegend.CanvasChanged(Sender);
end;
function TLegendItem.GetFont:TTeeFont;
@@ -5542,7 +5545,12 @@ begin
else
FFont:=TTeeFont.Create(nil);
+ {$IFDEF FMX}
+ FFont.Brush.OnChanged:=FontChanged;
+ {$ELSE}
FFont.OnChange:=FontChanged;
+ {$ENDIF}
+
result:=FFont;
end;
Re: Pie Chart Legend bug or my missing call?
Posted: Wed Jun 18, 2025 1:41 pm
by 16493447
Hello Yeray,
Thank you. It compiles now, and the legends work as intended.
I have another new issue (besides titles and stretching during printing), now it just stops when printing the charts (or takes a really long time...not sure):

- Freeze.png (55.14 KiB) Viewed 3107 times
John
Re: Pie Chart Legend bug or my missing call?
Posted: Wed Jun 18, 2025 1:43 pm
by 16493447
It did eventually print after a few minutes.
Re: Pie Chart Legend bug or my missing call?
Posted: Wed Jun 18, 2025 3:15 pm
by yeray
Hello,
I'm not sure to understand the problems you are experiencing with printing.
Could you please arrange a simple example project we can run as-is to reproduce the problem here?
Thanks in advance.
Re: Pie Chart Legend bug or my missing call?
Posted: Wed Jun 18, 2025 4:34 pm
by 16493447
Sure. Here is a quick little program:

- Program.png (8.41 KiB) Viewed 3061 times
(btw, the title was set to left justified alignment)
Here is a PDF print of that:

- PDF_Out.png (4.86 KiB) Viewed 3061 times
The Sample Project Zip is attached.
It's giving me all types of hell. I just compiled a Release version and lost the center alignment on the circular gauges. it works with Debug still, though.
John
Re: Pie Chart Legend bug or my missing call?
Posted: Wed Jun 18, 2025 4:36 pm
by 16493447
It seems like using anything but the default center alignment for the title does odd stuff.
Re: Pie Chart Legend bug or my missing call?
Posted: Thu Jun 19, 2025 4:53 pm
by 16493447
I have another printing issue that I would like to resolve if possible. The pie chart really stretches and the margins look way bigger.
Here is the pie chart on the screen:

- PieOnScreen.png (16.38 KiB) Viewed 2797 times
And here it is printed to PDF:

- PieInPrint.png (28.92 KiB) Viewed 2797 times
I am using the ChartPrintRect and the aspect ratios of screen vs print rect are the same, but it always squishes the image.
John
Re: Pie Chart Legend bug or my missing call?
Posted: Mon Jun 23, 2025 12:55 pm
by 16493447
?