Page 1 of 1

Need a link between legend and chart series

Posted: Tue Mar 07, 2006 1:31 pm
by 9640087
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

Posted: Tue Mar 07, 2006 2:22 pm
by narcis
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
			}

Posted: Wed Mar 08, 2006 9:29 am
by 9640087
Thanks NarcĂ­s, that worked perfectly.

JGM