Remove series using mouse event

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
pw
Newbie
Newbie
Posts: 57
Joined: Fri Nov 15, 2002 12:00 am

Remove series using mouse event

Post by pw » Thu Jul 23, 2009 2:07 am

Hi,

If there are a few different series (line or other types) on a chart, is it possible to remove a selected series using a MouseClick event?

Thanks.

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

Re: Remove series using mouse event

Post by Narcís » Thu Jul 23, 2009 1:06 pm

Hello,

Yes, the easiest way I can think of is using ClickSeries event or MouseDown events as shown below.

Code: Select all

		public Form1()
		{
			InitializeComponent();
			InitializeChart();
		}

		private void InitializeChart()
		{
			Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
			line1.FillSampleValues();

			tChart1.MouseDown += new MouseEventHandler(tChart1_MouseDown);
			tChart1.ClickSeries += new Steema.TeeChart.TChart.SeriesEventHandler(tChart1_ClickSeries);
		}

		void tChart1_ClickSeries(object sender, Steema.TeeChart.Styles.Series s, int valueIndex, MouseEventArgs e)
		{
			tChart1.Series.Remove(s);
		}

		void tChart1_MouseDown(object sender, MouseEventArgs e)
		{			
			for (int i = 0; i < tChart1.Series.Count; i++)
			{
				int series = tChart1[i].Clicked(e.X, e.Y);

				if (series != -1)
				{
					tChart1.Series.Remove(tChart1[i]);
					break;
				}
			}			
		}
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

pw
Newbie
Newbie
Posts: 57
Joined: Fri Nov 15, 2002 12:00 am

Re: Remove series using mouse event

Post by pw » Wed Aug 05, 2009 4:34 am

Thanks, Narcis.

Post Reply