View only active series in legend

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
yair
Newbie
Newbie
Posts: 15
Joined: Wed Jan 16, 2008 12:00 am

View only active series in legend

Post by yair » Sun May 18, 2008 2:09 pm

Q1: I'd like to see in the legend only the currently active series, how could I accomplish that ?

Q2: when hovring the mouse over a fastline series (or line series) The MarksTip tool shows the value of the last point in the series before the location of the mouse instead of the actual calculated value at the position on the line series (eg. between 2 points). how can i show the actual value between the points ?

Regards,
Yair

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

Post by Narcís » Mon May 19, 2008 8:59 am

Hi Yair,

1. You can do something like this:

Code: Select all

			foreach (Steema.TeeChart.Styles.Series s in tChart1.Series)
			{
				s.ShowInLegend = s.Active;
			}
2. You can achieve that as in the All Features\Welcome !\Chart styles\Standard\Line(Strip)\Interpolating line series example at the features demo, available at TeeChart's program group.
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

yair
Newbie
Newbie
Posts: 15
Joined: Wed Jan 16, 2008 12:00 am

Post by yair » Mon May 19, 2008 10:42 am

Excellent.

problem 1 - solved.

Regarding problem 2:
Using the MarksTip tool, is there a way I can get the x value between 2 of the series' points currently pointed to by the mouse, in order to use it in the interpolation of y ?
Also, how can i tell which is the series currently pointed to by the mouse ?

Thanks and best regards,
Yair

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

Post by Narcís » Mon May 19, 2008 1:19 pm

Hi Yair,

In that case you can use something like code 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.MouseMove += new MouseEventHandler(tChart1_MouseMove);
			Steema.TeeChart.Tools.MarksTip marksTip1 = new Steema.TeeChart.Tools.MarksTip(tChart1.Chart);
			marksTip1.GetText += new Steema.TeeChart.Tools.MarksTipGetTextEventHandler(marksTip1_GetText);

		}

		void marksTip1_GetText(Steema.TeeChart.Tools.MarksTip sender, Steema.TeeChart.Tools.MarksTipGetTextEventArgs e)
		{
			if (index != -1)
			{
				e.Text = "Series" + i.ToString() + ": " + xVal.ToString() + " / " + yVal.ToString();
			}
		}

		private double xVal, yVal;
		private int index = -1;
		private int i;


		void tChart1_MouseMove(object sender, MouseEventArgs e)
		{
			index = -1;

			for (i = 0; i < tChart1.Series.Count; i++)
			{
				index = tChart1[i].Clicked(e.X, e.Y);

				if (index != -1)
				{
					xVal = tChart1.Axes.Left.CalcPosPoint(e.X);
					yVal = tChart1.Axes.Left.CalcPosPoint(e.Y);

					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

yair
Newbie
Newbie
Posts: 15
Joined: Wed Jan 16, 2008 12:00 am

Post by yair » Tue May 20, 2008 1:47 pm

Perfect !

Many Thanks.

Post Reply