TreeMap - Issue with Marks Tool Tips

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
TimeAcct
Newbie
Newbie
Posts: 43
Joined: Wed Sep 03, 2008 12:00 am

TreeMap - Issue with Marks Tool Tips

Post by TimeAcct » Tue Jun 01, 2010 6:06 pm

Hello,

When I implemented the MarksToolTips - it works great for Labels - but the Value and Percents are not correct.
They seem to be based on the Special Value - not the actual value assigned to the series elements

Let me know if you need a sample

Bradley MacDonald
brad_AT_timeacct_DOT_com

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

Re: TreeMap - Issue with Marks Tool Tips

Post by Yeray » Wed Jun 02, 2010 3:22 pm

Hi Bradley,

Note that the TreeMap series stores the "values" in the XValue array and the relationship in the YValue array.
So, to make the marks show the "value" you could do:

Code: Select all

ChartTool1.Style:=smsXValue;
Regarding the smsPercentage, you are right, it doesn't seem to work as expected. I've added it to the wish list to be implemented in future releases (TV52014927).
In the meanwhile, note that the marks can be customized with the OnGetSeriesMark event. Here it is an example:

Code: Select all

  private
    { Private declarations }
      procedure Series1GetMarkText(Sender: TChartSeries; ValueIndex: Integer; var MarkText: String);

//...

uses TeeOrgSeries, TeeTreeMapSeries, TeeTools;

var treemap1: TTreeMapSeries;
    markstip1: TMarksTipTool;

procedure TForm1.FormCreate(Sender: TObject);
begin
  treemap1:=Chart1.AddSeries(TTreeMapSeries.Create(self)) as TTreeMapSeries;
  markstip1:=Chart1.Tools.Add(TMarksTipTool.Create(self)) as TMarksTipTool;

  treemap1.Add(100,'A',-1);
  treemap1.Add(75,'B',0);
  treemap1.Add(25,'C',0);

  treemap1.OnGetMarkText:=Series1GetMarkText;
  markstip1.Style:=smsPercent;
end;

procedure TForm1.Series1GetMarkText(Sender: TChartSeries; ValueIndex: Integer; var MarkText: String);
var i, tmpCount: Integer;
    tmpTotal: Double;
begin
  tmpCount:=0;
  tmpTotal:=0;

  for i:=0 to Sender.Count-1 do
  begin
    if Sender.YValue[i]=Sender.YValue[ValueIndex] then
    begin
      tmpTotal:=tmpTotal+Sender.XValue[i];
      tmpCount:=tmpCount+1;
    end;
  end;

  MarkText:=FormatFloat('#,##%',Sender.XValue[ValueIndex]*100/tmpTotal);
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

TimeAcct
Newbie
Newbie
Posts: 43
Joined: Wed Sep 03, 2008 12:00 am

Re: TreeMap - Issue with Marks Tool Tips

Post by TimeAcct » Wed Jun 02, 2010 3:25 pm

Yeray,

Thank you very much! I must say the support in these forums is outstanding.
In the last few days you have answered all my questions - and even sent source code - and a patch.

Very impressive!

Bradley MacDonald

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

Re: TreeMap - Issue with Marks Tool Tips

Post by Yeray » Wed Jun 02, 2010 3:33 pm

Hi Bradley,

I'm glad to see you satisfied with it!
And thanks for the praises! :oops:
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

Post Reply