Page 1 of 1

Get a BarSeries by Index

Posted: Thu Dec 06, 2007 2:19 pm
by 4210526
Hello supportteam,

I am using Delphi 6 and TeeChart Pro v5.02.

I have a teechart with a dynamic amount of series.

Image
Big version

So i add Series1 for 'Line19', 'Line20' and for 'Line21'. So i have three bars displayed but only one series.
When i add this series i would like to add the index of this three bars to a list.

But how can i do this? How do i know the index e.g. for Series1 'Line21'?

Background information:
When i add the series i would like to add the series index to a list with more information about this bar.

Then i would like to add a individual mark text for each displayed bar in the 'OnMarkTextEvent'.

Do you know a better way how to tagging a bar to add a individual mark text?

Posted: Fri Dec 07, 2007 1:36 am
by 10546565
OnMarkTextEvent has an index param (ValueText), so you should be able to to the value--or am I missing something?

Posted: Fri Dec 07, 2007 8:13 am
by 4210526
Thanks for the answer.

Yep thats right.. but i need the index param when i am adding a value to the bar --> outside the OnMarkTextEvent.

I need this because i would like to save more information about this bar in a list when adding a y value to the bar. Then in the OnMarkTextEvent i would like to search the list items which one has the same index param and then add a mark text that is in the list item to show an individual text for every bar.



Hope thats clear. Thanks!

Posted: Fri Dec 07, 2007 10:22 am
by narcis
Hi AChatSoluions,

You can obtain each series and point indexes like this:

Code: Select all

Uses Series;

procedure TForm1.FormCreate(Sender: TObject);
var SeriesIndex, ValueIndex: Integer;
    tmpSeries: TChartSeries;
begin
  tmpSeries:=Chart1.AddSeries(TBarSeries.Create(self));
  SeriesIndex:=Chart1.SeriesList.IndexOf(tmpSeries);

  ValueIndex:=Chart1.Series[SeriesIndex].Add(random);

  Chart1.Title.Text.Clear;
  Chart1.Title.Text.Add(IntToStr(SeriesIndex));
  Chart1.Title.Text.Add(IntToStr(ValueIndex));
end;
Hope this helps!

Posted: Tue Dec 11, 2007 4:10 pm
by 4210526
Thank you very much, it works :D