Page 1 of 1

TreeMap - Issue with Marks Tool Tips

Posted: Tue Jun 01, 2010 6:06 pm
by 10550242
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

Re: TreeMap - Issue with Marks Tool Tips

Posted: Wed Jun 02, 2010 3:22 pm
by yeray
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;

Re: TreeMap - Issue with Marks Tool Tips

Posted: Wed Jun 02, 2010 3:25 pm
by 10550242
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

Re: TreeMap - Issue with Marks Tool Tips

Posted: Wed Jun 02, 2010 3:33 pm
by yeray
Hi Bradley,

I'm glad to see you satisfied with it!
And thanks for the praises! :oops: