How do I read first series selected from legend checkboxes?

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Dave
Advanced
Posts: 137
Joined: Mon Sep 22, 2008 12:00 am

How do I read first series selected from legend checkboxes?

Post by Dave » Mon May 06, 2013 10:39 am

Hi

If there are say 10 series on the chart and there is checkboxes on the chart legend to allow selection of each one how do I get the first selected series (ie. the first series with the checkbox checked).We are using TeeChart version 3.5.3187.15585 and C#.NET

Thanks

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: How do I read first series selected from legend checkboxes?

Post by Sandra » Mon May 06, 2013 3:27 pm

Hello Dave,

I have made a simple code that I think help you to achieve as you want:

Code: Select all

public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }
        Steema.TeeChart.Styles.FastLine line1, line2, line3, line4;
        private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;
            line1 = new FastLine(tChart1.Chart);
            line2 = new FastLine(tChart1.Chart);
            line3 = new FastLine(tChart1.Chart);
            line4 = new FastLine(tChart1.Chart);
            line1.FillSampleValues();
            line2.FillSampleValues();
            line3.FillSampleValues();
            line4.FillSampleValues();

            tChart1.Legend.CheckBoxes = true;
            tChart1.ClickLegend += new MouseEventHandler(tChart1_ClickLegend);
            tChart1.Draw();
        }
        bool isFirstVisible; 
        int index;
        void tChart1_ClickLegend(object sender, MouseEventArgs e)
        {
            index = 0;
            isFirstVisible = false;
            while(index<tChart1.Series.Count && !isFirstVisible)
            {
                if (tChart1[index].Active)
                {
                    isFirstVisible = true; 
                }
                else
                {
                    isFirstVisible = false; 
                    index++; 
                }
            }
            if (isFirstVisible)
            {
                this.Text = tChart1[index].Title; 
            }
        }
Could you tell us if previous code works as you want?

Thanks,
Best Regards,
Sandra Pazos / 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

Post Reply