Page 1 of 1
Creation of Custom Functions
Posted: Tue Sep 01, 2015 12:16 pm
by 16071129
Hi,
We have a requirement wherein user requires to create Custom Functions out of available TeeChart Functions on Design Time (or say at run time).
For example, as shown in below screenshots user needs to develop a new custom function by using following formula at design time.
New Custom Function= (Smoothing + Trend) / Exp. Trend
It would be great if you can add another tab as "Custom Functions" and let user to build his own custom functions by using some means such as formula builder. It will going to be a ultimate feature of your TeeChart Control.
- TeeChart Functions
- custom functions.png (49.43 KiB) Viewed 13472 times
Re: Creation of Custom Functions
Posted: Tue Sep 01, 2015 1:50 pm
by Christopher
Hello,
Some of this is already available in TeeChart. In the tutorials under:
%Program Files%\Steema Software\Steema TeeChart for .NET 2015 4.1.2015.08060\Docs\TeeChart for .Net Tutorials.chm
look under "Tutorial 7 - Working with Functions -> Deriving Custom Functions". In code, this is:
Code: Select all
public class SquareSum : Steema.TeeChart.Functions.Function
{
public SquareSum() : base() { }
public SquareSum(Steema.TeeChart.Chart c) : base(c) { }
public override double Calculate(Series SourceSeries, int FirstIndex, int LastIndex)
{
ValueList v = ValueList(SourceSeries);
if (FirstIndex == -1) return v.Total;
else
{
double result = 0;
for (int t = FirstIndex; t <= LastIndex; t++)
result += Math.Sqrt(v[t]);
return result;
}
}
public override string Description()
{
return "Custom SquareSum";
}
public override double CalculateMany(ArrayList SourceSeriesList, int ValueIndex)
{
ValueList v;
double result = 0;
for (int t = 0; t < SourceSeriesList.Count; t++)
{
v = ValueList((Series)SourceSeriesList[t]);
if (v.Count > ValueIndex)
result += Math.Sqrt(v[ValueIndex]);
}
return result;
}
}
and can be used:
Code: Select all
Line series1, series2;
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
series1 = new Line(tChart1.Chart);
series2 = new Line(tChart1.Chart);
series1.FillSampleValues();
series2.VertAxis = VerticalAxis.Right;
series2.Function = new SquareSum(tChart1.Chart);
series2.DataSource = series1;
Utils.RegisterFunction(typeof(SquareSum), 0);
}
notice the RegisterFunction - this registers the function with the Chart Editor, which when opened now looks like:
- squaresum.PNG (20.62 KiB) Viewed 13456 times
Re: Creation of Custom Functions
Posted: Wed Sep 02, 2015 3:55 am
by 16071129
Hi,
That is great example, but how about giving a formula builder for doing the same, taking into account that user's don't have any programming knowledge.
Re: Creation of Custom Functions
Posted: Wed Sep 30, 2015 9:09 am
by 16071129
Awaiting your reply on this.
Re: Creation of Custom Functions
Posted: Wed Sep 30, 2015 9:30 am
by Christopher
It is an interesting suggestion, and like all such suggestions can be added by yourself to our issue tracking software here:
http://bugs.teechart.net/
Thank you very much for continuing to think of new suggestions for TChart!
Re: Creation of Custom Functions
Posted: Wed Sep 30, 2015 12:14 pm
by 16071129
Hi,
We don't have login credentials for
http://bugs.teechart.net/. Can we use our customer/license number? Please provide some help on this.
Re: Creation of Custom Functions
Posted: Wed Sep 30, 2015 12:22 pm
by Christopher
Quant wrote:Hi,
We don't have login credentials for
http://bugs.teechart.net/. Can we use our customer/license number? Please provide some help on this.
Of course. Please click on the "New Account" link as seen here:
- new_account.PNG (80.08 KiB) Viewed 13390 times
and then follow the given instructions.