Pie Chart Legend bug or my missing call?

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
JNuzzi
Newbie
Newbie
Posts: 38
Joined: Mon Mar 21, 2022 12:00 am

Pie Chart Legend bug or my missing call?

Post by JNuzzi » Mon Jun 16, 2025 7:26 pm

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
Chart1.png (34.22 KiB) Viewed 3499 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
Chart2.png (29 KiB) Viewed 3499 times
Thank you,

John

Yeray
Site Admin
Site Admin
Posts: 9709
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Pie Chart Legend bug or my missing call?

Post by Yeray » Tue Jun 17, 2025 2:49 pm

Hello John,

I've seen the fix for #1210 in TeeChart v2025.44 breaks this.
We are revising it.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

JNuzzi
Newbie
Newbie
Posts: 38
Joined: Mon Mar 21, 2022 12:00 am

Re: Pie Chart Legend bug or my missing call?

Post by JNuzzi » Tue Jun 17, 2025 5:54 pm

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
PrintPartialCanvas.png (70.44 KiB) Viewed 3324 times
I was going to go tinkering around in the code, but figured I would point it out anyway.

Thanks,

John

JNuzzi
Newbie
Newbie
Posts: 38
Joined: Mon Mar 21, 2022 12:00 am

Re: Pie Chart Legend bug or my missing call?

Post by JNuzzi » Tue Jun 17, 2025 5:57 pm

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...

JNuzzi
Newbie
Newbie
Posts: 38
Joined: Mon Mar 21, 2022 12:00 am

Re: Pie Chart Legend bug or my missing call?

Post by JNuzzi » Tue Jun 17, 2025 6:36 pm

I figured maybe I could get around it by drawing to a Bitmap, then painting that to the printer. I got this:
Bitmap.png
Bitmap.png (28.66 KiB) Viewed 3312 times
John

Yeray
Site Admin
Site Admin
Posts: 9709
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Pie Chart Legend bug or my missing call?

Post by Yeray » Tue Jun 17, 2025 8:12 pm

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;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

JNuzzi
Newbie
Newbie
Posts: 38
Joined: Mon Mar 21, 2022 12:00 am

Re: Pie Chart Legend bug or my missing call?

Post by JNuzzi » Wed Jun 18, 2025 2:51 am

Hello, I am getting a compile error with those changes:
Compile.png
Compile.png (55.19 KiB) Viewed 3245 times
John

Yeray
Site Admin
Site Admin
Posts: 9709
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Pie Chart Legend bug or my missing call?

Post by Yeray » Wed Jun 18, 2025 8:29 am

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;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

JNuzzi
Newbie
Newbie
Posts: 38
Joined: Mon Mar 21, 2022 12:00 am

Re: Pie Chart Legend bug or my missing call?

Post by JNuzzi » Wed Jun 18, 2025 1:41 pm

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
Freeze.png (55.14 KiB) Viewed 3082 times
John

JNuzzi
Newbie
Newbie
Posts: 38
Joined: Mon Mar 21, 2022 12:00 am

Re: Pie Chart Legend bug or my missing call?

Post by JNuzzi » Wed Jun 18, 2025 1:43 pm

It did eventually print after a few minutes.

Yeray
Site Admin
Site Admin
Posts: 9709
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Pie Chart Legend bug or my missing call?

Post by Yeray » Wed Jun 18, 2025 3:15 pm

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.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

JNuzzi
Newbie
Newbie
Posts: 38
Joined: Mon Mar 21, 2022 12:00 am

Re: Pie Chart Legend bug or my missing call?

Post by JNuzzi » Wed Jun 18, 2025 4:34 pm

Sure. Here is a quick little program:
Program.png
Program.png (8.41 KiB) Viewed 3036 times
(btw, the title was set to left justified alignment)

Here is a PDF print of that:
PDF_Out.png
PDF_Out.png (4.86 KiB) Viewed 3036 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
Attachments
SamplePrintError.zip
(9.96 KiB) Downloaded 63 times

JNuzzi
Newbie
Newbie
Posts: 38
Joined: Mon Mar 21, 2022 12:00 am

Re: Pie Chart Legend bug or my missing call?

Post by JNuzzi » Wed Jun 18, 2025 4:36 pm

It seems like using anything but the default center alignment for the title does odd stuff.

JNuzzi
Newbie
Newbie
Posts: 38
Joined: Mon Mar 21, 2022 12:00 am

Re: Pie Chart Legend bug or my missing call?

Post by JNuzzi » Thu Jun 19, 2025 4:53 pm

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
PieOnScreen.png (16.38 KiB) Viewed 2772 times
And here it is printed to PDF:
PieInPrint.png
PieInPrint.png (28.92 KiB) Viewed 2772 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

JNuzzi
Newbie
Newbie
Posts: 38
Joined: Mon Mar 21, 2022 12:00 am

Re: Pie Chart Legend bug or my missing call?

Post by JNuzzi » Mon Jun 23, 2025 12:55 pm

?

Post Reply