Showing legend names (not series names) as bar marks....

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Mortong
Newbie
Newbie
Posts: 15
Joined: Mon Mar 29, 2004 5:00 am
Location: london

Showing legend names (not series names) as bar marks....

Post by Mortong » Wed Apr 07, 2004 6:18 pm

I have two series - Called Male and Female with values alf and John in one and anne, georgina and rose in the other

I do a stacked bar chart, set the legend to the values so it looks like two bars with legends showing the individual names - perfect. The "marks" however show M or F NOT the names as per the legend - is this a bug.... Can I get round it??

Am just being stupid?

Running D7 and Teechart Pro 7...

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Thu Apr 08, 2004 9:57 am

Hi,

to show the Series Names in the Marks you will have to customize the MarkText using the OnGetMarkText event like :

Code: Select all

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

Mortong
Newbie
Newbie
Posts: 15
Joined: Mon Mar 29, 2004 5:00 am
Location: london

Post by Mortong » Thu Apr 08, 2004 11:01 am

Thnaks BUT....

Two things

Firstly there may be 50 series of which 49 are temporary so how can you allocate the getmarkseries function to a series by its number?

Secondly, its not the title of the series I am after but the value of the item within the series - ie fred, ann or bill...

Thank you thus far

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Fri Apr 09, 2004 4:34 am

Hi.
Firstly there may be 50 series of which 49 are temporary so how can you allocate the getmarkseries function to a series by its number?
A simple for loop should do the trick:

Code: Select all

procedure TForm1.YourOnMarkTextEvent(Sender: TChartSeries;
  ValueIndex: Integer; var MarkText: String);
begin
  MarkText := Sender.XLabels[ValueIndex];
end;

for i := 0 to Chart1.SeriesCount-1 do
 Chart1.Series[i].OnGetMarkText := YourOnMarkTextEvent;
Marjan Slatinek,
http://www.steema.com

Mortong
Newbie
Newbie
Posts: 15
Joined: Mon Mar 29, 2004 5:00 am
Location: london

Post by Mortong » Wed Apr 14, 2004 4:04 pm

Thank you...

Here's a different tack that seems to work (only on stacked charts though)

procedure Trewritealone.ChartTool1GetText(Sender: TMarksTipTool;
var Text: String);
var t,tmp:integer;
x,y:double;
begin
chart1.Series[0].GetCursorValues(x,y);
for t:=0 to chart1.seriescount-1 do
begin
tmp:=chart1.Series[t].GetCursorValueIndex;
if tmp<>-1 then
text:=chart1.series[t].title+' '+floattostr(chart1.series[t].YValue[tmp]);
end;
end;

Post Reply