Page 1 of 1

Remove series using mouse event

Posted: Thu Jul 23, 2009 2:07 am
by 6923298
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.

Re: Remove series using mouse event

Posted: Thu Jul 23, 2009 1:06 pm
by narcis
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;
				}
			}			
		}

Re: Remove series using mouse event

Posted: Wed Aug 05, 2009 4:34 am
by 6923298
Thanks, Narcis.