Legend, show Series Name and Series Total Value

TeeChart FireMonkey (Windows,OSX,iOS & Android) for Embarcadero RAD Studio, Delphi and C++ Builder (XE5+)
Post Reply
realsol
Newbie
Newbie
Posts: 70
Joined: Mon Feb 27, 2017 12:00 am

Legend, show Series Name and Series Total Value

Post by realsol » Wed Mar 15, 2017 7:21 pm

I have attached my chart. How can I change the legend to show the Series Name along with the Total value of the Series?
Attachments
2017-03-15_1212.png
2017-03-15_1212.png (43.43 KiB) Viewed 19562 times

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

Re: Legend, show Series Name and Series Total Value

Post by Yeray » Thu Mar 16, 2017 1:17 pm

Hello,

You could use OnGetLegendText event. Ie:

Code: Select all

procedure TForm1.Chart1GetLegendText(Sender: TCustomAxisPanel;
  LegendStyle: TLegendStyle; Index: Integer; var LegendText: string);
var i: Integer;
begin
  if Index<Chart1.SeriesCount then
    LegendText:=LegendText + ' $' + FormatFloat('#,##0.##', Chart1[Index].YValues.Total);
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

realsol
Newbie
Newbie
Posts: 70
Joined: Mon Feb 27, 2017 12:00 am

Re: Legend, show Series Name and Series Total Value

Post by realsol » Thu Mar 16, 2017 2:28 pm

Thank you. I'll give it a shot.

realsol
Newbie
Newbie
Posts: 70
Joined: Mon Feb 27, 2017 12:00 am

Re: Legend, show Series Name and Series Total Value

Post by realsol » Thu Jul 13, 2017 5:36 pm

I have another question along this same lines. I have a pie chart of categories (Attached). If transactions don't have any assigned category, the legend just displays the amount. I would like to add the text 'No Categories' in front of the amount but I can't seem to format it the way it is in the legend (Text left justified and amount right justified).

Thanks.
Attachments
2017-07-13_1028.png
2017-07-13_1028.png (29.42 KiB) Viewed 19361 times

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

Re: Legend, show Series Name and Series Total Value

Post by Yeray » Fri Jul 14, 2017 7:18 am

Hello,
realsol wrote:I have another question along this same lines. I have a pie chart of categories (Attached). If transactions don't have any assigned category, the legend just displays the amount. I would like to add the text 'No Categories' in front of the amount but I can't seem to format it the way it is in the legend (Text left justified and amount right justified).
I'm not sure to understand why don't you add the uncategorized value as you do with the others, with the "No Categories" label. Ie:

Code: Select all

  Series1.Add(316560, 'No Categories');
In case you are adding the values connecting the series to a dataset, you can loop your values and set the label at those points with empty labels. Ie:

Code: Select all

  for i:=0 to Series1.Count-1 do
    if Series1.Labels[i] = '' then
      Series1.Labels[i]:='No Categories';
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

realsol
Newbie
Newbie
Posts: 70
Joined: Mon Feb 27, 2017 12:00 am

Re: Legend, show Series Name and Series Total Value

Post by realsol » Fri Jul 14, 2017 6:00 pm

Thanks. I ended up using the OnGetLegendText for the Chart and added

Code: Select all

if Series1.Labels[Index] = '' then
      Series1.Labels[index]:='No Categories';
Worked perfectly. Thanks.

Post Reply