OnGetMarkText - customize text of Mark Tips only, not Marks

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
marder
Advanced
Posts: 115
Joined: Thu May 29, 2008 12:00 am

OnGetMarkText - customize text of Mark Tips only, not Marks

Post by marder » Fri Jul 31, 2009 8:36 am

Hi.

I wonder if there is a way to customize the text shown in the "Mark Tips", without customizing the text shown in the actual marks of the series.
Note: I want to customize the mark tips shown when the mouse stays over one of my pie chart slice, without customizing the always shown marks of each slice.
I know that I can use the OnGetMarkText Event to customize mark texts, but this will customize both, the always shown marks and the mark tips of my pie chart.

Any idea how to resolve this?

Thanks!

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

Re: OnGetMarkText - customize text of Mark Tips only, not Marks

Post by Yeray » Fri Jul 31, 2009 10:44 am

Hi marder,

Note that there is a OnGetMarkText event for the mark tips tool too:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
  Series1.Clear;

  Series1.Add(random*100, 'first');
  Series1.Add(random*100, 'second');
  Series1.Add(random*100, 'third');
  Series1.Add(random*100, 'fourth');
  Series1.Add(random*100, 'fifth');
  Series1.Add(random*100, 'sixth');

  Series1.Marks.Style := smsLabel;

  ChartTool1.Style := smsValue;
end;

procedure TForm1.ChartTool1GetText(Sender: TMarksTipTool;
  var Text: String);
var i:Integer;
begin
  for i:=0 to Series1.Count-1 do
  begin
    if ChartTool1.Style = smsValue then
    begin
      if (FormatFloat('#.###', Series1.YValue[i]) = Text) then
      begin
        Text := 'label number ' + inttostr(i+1);
        Exit;
      end;
    end
    else
    if ChartTool1.Style = smsLabel then
    begin
      if (Series1.Labels[i] = Text) then
      begin
        Text := 'label number ' + inttostr(i+1);
        Exit;
      end;
    end
  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

marder
Advanced
Posts: 115
Joined: Thu May 29, 2008 12:00 am

Re: OnGetMarkText - customize text of Mark Tips only, not Marks

Post by marder » Fri Jul 31, 2009 2:57 pm

Hi Yeray.

Thanks for this information!
My problem is, that I have to customize both mark texts in different ways.
When I use the OnGetMarkText event to customize the "always shown marks" only, it seams that the default text of the "mark tips" is also customized.
This is a problem in my case, because I in some cases I want to cut the labels form the "always shown marks" and do show them only in the "mark tips". The problem is, that in the OnGetText Event of the Mark Tip I have no access to the current index so I cannot bring my label up again.

I hope you understand what I mean (It's some kind of tricky)

The perfect solution for me would be if:
1. The OnGetMarkText would not influence the text of the "mark tips", but only of the "always shown marks"
or
2. There was some kind of flag in the OnGetMarkText Event, so I could identify if this is the text for a mark tip or not.

Thanks for your help!

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

Re: OnGetMarkText - customize text of Mark Tips only, not Marks

Post by Yeray » Mon Aug 03, 2009 8:33 am

Hi marder,

I'll add your suggestions to the wish list to be considered for inclusion in future releases.

In the meanwhile you still could loop your series marks at the mark tips tool OnGetMarkText event and use the given text to retrieve the value index for that mark. Here is an example:

Code: Select all

function TForm1.GetMark(ValueIndex:Integer):String;
begin
  result := 'label number ' + inttostr(ValueIndex+1)
end;

procedure TForm1.Series1GetMarkText(Sender: TChartSeries;
  ValueIndex: Integer; var MarkText: String);
begin
  MarkText := GetMark(ValueIndex);
end;

procedure TForm1.ChartTool1GetText(Sender: TMarksTipTool;
  var Text: String);
var i:Integer;
begin
  for i:=0 to Series1.Count-1 do
  begin
    if ( Text = GetMark(i) ) then
    begin
      Text := 'label #' + inttostr(i+1);
      Exit;
    end;
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  Series1.Clear;
  for i:=0 to 6 do
    Series1.Add(random*100, 'number ' + inttostr(i));
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

marder
Advanced
Posts: 115
Joined: Thu May 29, 2008 12:00 am

Re: OnGetMarkText - customize text of Mark Tips only, not Marks

Post by marder » Tue Aug 04, 2009 12:41 pm

Thanks for your help and for adding this to the wish list!

Post Reply