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 13455 times