Page 1 of 1

Data from the series in ganttchart

Posted: Wed Jul 27, 2005 2:51 pm
by 9637231
In dotnet everything is different from the windows versions.
It's so unclear. I work in delphi dotnet.

How can I get the seriesdata if I point at a seriesitem in the ganttchart?

I want the index of the record and the x(datevalue) and the y values.

Hans

Posted: Thu Jul 28, 2005 10:44 am
by narcis
Hi Hans,

Are you working in a VCL.NET project or a Delphi for .NET Windows Forms project? Anyway, you shouldn't have much problems, the code snippet below is in C# but can be easily ported to VCL.

Code: Select all

		private void gantt1_Click(object sender, System.Windows.Forms.MouseEventArgs e)
		{
			int index=gantt1.Clicked(e.X,e.Y);

			tChart1.Header.Text="Index: " + index.ToString() +
													" Value: " + (DateTime.FromOADate(gantt1.XValues[index])).ToString() + 
													" - " + gantt1.YValues[index].ToString();						
		}

Posted: Thu Jul 28, 2005 11:33 am
by 9637231
OK, thanks I will try this.

And how do I get the index if I only point(mouseenter event) and not click at the points?

Hans

Posted: Thu Jul 28, 2005 11:48 am
by narcis
Hi Hans,

It would be quite similar, you should use tChart's MouseMove event and implement something like:

Code: Select all

		private void tChart1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
		{
			int index=gantt1.Clicked(e.X,e.Y);

			if (index != -1)
				tChart1.Header.Text="Index: " + index.ToString() +
														" Value: " + (DateTime.FromOADate(gantt1.XValues[index])).ToString() + 
														" - " + gantt1.YValues[index].ToString();						
			else tChart1.Header.Text="";
		}

Posted: Thu Jul 28, 2005 2:45 pm
by 9637231
Is it not possible to use Gantt1_MouseEnter and Gantt1_MouseLeave, because those are the events for moving over a seriespoint?

Posted: Thu Jul 28, 2005 3:06 pm
by narcis
Hi Hans,

Those events don't have X and Y coordinates parameters to get the index you request with Clicked method.

Posted: Thu Jul 28, 2005 5:07 pm
by 9637231
Narcis,

OK, clear, but what is the function of those 2 events. What can we do, read, edit, etc. in those events?

Hans

Posted: Fri Jul 29, 2005 9:09 am
by narcis
Hi Hans,

You could manage to read values or so by manually getting mouse coordinates or capturing them from MouseMove event and using Clicked method as I showed you before. However, those events can also be used for other kinds of interaction as, for example, changing one series appearence when mouse being over it.