Can we create our own Custom Function ?

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
spacemanspiff
Newbie
Newbie
Posts: 10
Joined: Fri Jul 02, 2004 4:00 am
Contact:

Can we create our own Custom Function ?

Post by spacemanspiff » Tue Sep 12, 2006 11:27 am

Hi,
These are lines of code as taken from the examples for plotting functions in TeeChart:

Custom function to calculate y = f(x) values using a CalculateEvent:

private void custom1_CalculateEvent(object sender, Steema.TeeChart.Functions.CalculateEventArgs e)
{
// y = Sin(x/10)
e.Y = Math.Sin(e.X*0.1);
}


I need to plot the function y = mx + c (a linear equation) in my graph.
How can I do it?
Note: I am using TChart ver 1.1

Thanks in Advance

Vikas Kashyap

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

Post by Narcís » Tue Sep 12, 2006 3:11 pm

Hi Vikas,

Have you tried doing something like this?

Code: Select all

		private void custom1_CalculateEvent(object sender, Steema.TeeChart.Functions.CalculateEventArgs e)
		{
			// y = Mx+C
			e.Y = e.X*m + c;
		}
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

sunjun
Newbie
Newbie
Posts: 8
Joined: Fri Oct 27, 2006 12:00 am

Defining custom CalculateEvent handler

Post by sunjun » Wed Jan 10, 2007 12:24 pm

I would like to ask how should I define the handler for my custom function?

Should it be something like this:

Code: Select all

myCustomFunction.CalculateEvent += custom1_CalculateEvent(XXXXXXXXXXXXXX
?

If so, how to form the proper list of arguments for this event handler?

A code snippet would be very handy, it's totally on fire!

Thanks in advance!

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

Post by Narcís » Wed Jan 10, 2007 12:30 pm

Hi sunjun,

You can call the event handler like this:

Code: Select all

			myCustomFunction.CalculateEvent += new Steema.TeeChart.Functions.CalculateEventHandler(myCustomFunction_CalculateEvent);
And event's implementation:

Code: Select all

		void myCustomFunction_CalculateEvent(object sender, Steema.TeeChart.Functions.CalculateEventArgs e)
		{
			throw new Exception("The method or operation is not implemented.");
		}
Also Visual Studio .NET really helps with this implementation, when you type myCustomFunction.CalculateEvent +=, after typing the equals symbol the code completion starts working nicelly and suggests the event handler call and it offers you the change to automatically generate the event implementation by pressing Tab key.
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

sunjun
Newbie
Newbie
Posts: 8
Joined: Fri Oct 27, 2006 12:00 am

Post by sunjun » Wed Jan 10, 2007 12:43 pm

Thanks a lot, Narcis!

I have adapted the code to my implementation and it works just nice. I will have to finalize the implementation of distribution function for our custom needs.

Best Wishes!

Post Reply