Creation of Custom Functions

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Quant
Advanced
Posts: 142
Joined: Tue Dec 30, 2014 12:00 am

Creation of Custom Functions

Post by Quant » Tue Sep 01, 2015 12:16 pm

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.
custom functions.png
TeeChart Functions
custom functions.png (49.43 KiB) Viewed 13642 times

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Creation of Custom Functions

Post by Christopher » Tue Sep 01, 2015 1:50 pm

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
squaresum.PNG (20.62 KiB) Viewed 13626 times
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Quant
Advanced
Posts: 142
Joined: Tue Dec 30, 2014 12:00 am

Re: Creation of Custom Functions

Post by Quant » Wed Sep 02, 2015 3:55 am

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.

Quant
Advanced
Posts: 142
Joined: Tue Dec 30, 2014 12:00 am

Re: Creation of Custom Functions

Post by Quant » Wed Sep 30, 2015 9:09 am

Awaiting your reply on this.

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Creation of Custom Functions

Post by Christopher » Wed Sep 30, 2015 9:30 am

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! :D
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Quant
Advanced
Posts: 142
Joined: Tue Dec 30, 2014 12:00 am

Re: Creation of Custom Functions

Post by Quant » Wed Sep 30, 2015 12:14 pm

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.

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Creation of Custom Functions

Post by Christopher » Wed Sep 30, 2015 12:22 pm

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
new_account.PNG (80.08 KiB) Viewed 13560 times
and then follow the given instructions.
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Post Reply