Need a link between legend and chart series

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
JGM
Newbie
Newbie
Posts: 3
Joined: Wed Jan 25, 2006 12:00 am

Need a link between legend and chart series

Post by JGM » Tue Mar 07, 2006 1:31 pm

Hi,

I have a number of series on my chart, but I don't display all the series in the chart's legend. I also have checkboxes enabled on the legend. Users can also add series to the chart - some of which will be displayed in the legend and some not.

I am trying to find a link between the items in the legend and their corresponding indices in the chart's series collection.

By way of illustration:

The following series exist on the chart:

Idx.
0 - Price
1 - Moving Average
3 - Bollinger band upper series
4 - Bollinger band lower series
5 - Moving Average #2
6 - MA #2's Bollinger upper series
7 - MA #2's Bollinger lower series

The following series are displayed in the legend:

Leg. Idx.
0 - Moving Average
1 - Bollinger upper series
2 - MA 2
3 - MA 2's Bollinger upper series

Each set of Bollinger bands (2 series) is represented by one legend item, so that the set can be activated/deactivated by one checkbox.

What I would ideally like to do in the ClickLegend handler is check whether the item clicked was a Bollinger band and if so, retrieve it's index in the chart's series collection so that whatever action is performed on the series will also be performed on it's 'partner' series, the Bollinger lower series which will always be at the next position.

I can retrieve the Legend index for the clicked item and I can also 'work with' it's corresponding series via tChart1.Chart.SeriesLegend(LegendIndex,false), but I can't retrieve the actual series index.

JGM

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Mar 07, 2006 2:22 pm

Hi JGM,

You can try using something like this:

Code: Select all

			if (tChart1[tChart1.Series.IndexOf(tChart1.Chart.SeriesLegend(LegendIndex,false))] is Steema.TeeChart.Functions.Bollinger)
			{
				//Your code here
			}
Or just:

Code: Select all

			if (tChart1.Chart.SeriesLegend(LegendIndex,false) is Steema.TeeChart.Functions.Bollinger)
			{
				//Your code here
			}
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

JGM
Newbie
Newbie
Posts: 3
Joined: Wed Jan 25, 2006 12:00 am

Post by JGM » Wed Mar 08, 2006 9:29 am

Thanks Narcís, that worked perfectly.

JGM

Post Reply