Page 1 of 1

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

Posted: Wed Apr 07, 2004 6:18 pm
by 9336918
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...

Posted: Thu Apr 08, 2004 9:57 am
by Pep
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;

Posted: Thu Apr 08, 2004 11:01 am
by 9336918
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

Posted: Fri Apr 09, 2004 4:34 am
by Marjan
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;

Posted: Wed Apr 14, 2004 4:04 pm
by 9336918
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;