Page 1 of 1

Can we create our own Custom Function ?

Posted: Tue Sep 12, 2006 11:27 am
by 8126031
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

Posted: Tue Sep 12, 2006 3:11 pm
by narcis
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;
		}

Defining custom CalculateEvent handler

Posted: Wed Jan 10, 2007 12:24 pm
by 9642919
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!

Posted: Wed Jan 10, 2007 12:30 pm
by narcis
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.

Posted: Wed Jan 10, 2007 12:43 pm
by 9642919
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!