mouseover label texts

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Lars Iversen
Newbie
Newbie
Posts: 61
Joined: Wed Jun 22, 2005 4:00 am
Location: cph

mouseover label texts

Post by Lars Iversen » Mon Nov 03, 2008 12:45 pm

Hi

I have a chart with some numeric values displayed as x-axis labels.
I would like to be able to move the mouse over one of these numbers and then do a database lookup to find the matching long descriptive text.
Is it possible to trigger on the mouse moving over an axis label and is it possible to show a kind of a popup box with the additional information (Or will I have to do that with a textbox or someting similar.?

Thanks in advance
Lars Iversen

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 Nov 03, 2008 1:07 pm

Hi Lars,

Yes, you can do something like this:

Code: Select all

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

		private void InitializeChart()
		{
			tChart1.Aspect.View3D = false;

			Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);

			line1.FillSampleValues();

			tChart1.Axes.Bottom.Labels.Style = Steema.TeeChart.AxisLabelStyle.Text;
			tChart1.MouseMove += new MouseEventHandler(tChart1_MouseMove);
			tChart1.GetAxisLabel += new Steema.TeeChart.GetAxisLabelEventHandler(tChart1_GetAxisLabel);
		}

		void tChart1_GetAxisLabel(object sender, Steema.TeeChart.GetAxisLabelEventArgs e)
		{
			if ((sender == tChart1.Axes.Bottom) && (e.Series != null))
			{
				e.LabelText = e.Series.XValues[e.ValueIndex].ToString();	
			}			
		}

		private Steema.TeeChart.Tools.Annotation annotation1;

		void tChart1_MouseMove(object sender, MouseEventArgs e)
		{			
			int index = tChart1.Axes.Bottom.Labels.Clicked(e.X, e.Y);

			tChart1.Tools.Clear();

			if (index != -1)
			{
				annotation1 = new Steema.TeeChart.Tools.Annotation(tChart1.Chart);
								
				annotation1.Text = "Long text I retrieved from DB";
				annotation1.Shape.CustomPosition = true;
				annotation1.Shape.Left = e.X;
				annotation1.Shape.Top = e.Y;
			}
		}
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

Post Reply