コード文字列またはイベントの使用の代替として、プログラマは ISimpleFunction インタフェースを実装しているオブジェクトのインスタンスを指定できます。そのようなオブジェクトをインタフェースから継承し、Calculate という名前のパブリック関数を実装しなければなりません。この Calculate メソッドは、独立変数(Double)をパラメータとして取り、従属変数(Double)を返します。
YFunction クラスのオブジェクトの場合、CustomFunction プロパティを ISimpleFunction インタフェース実装オブジェクトに設定する必要があります。ParametricFunction クラスのオブジェクトの場合、CustomFunctionX と CustomFunctionY の各プロパティを、ISimpleFunction インタフェースを実装している適切なオブジェクトに設定する必要があります。
Visual Basic コードの書き方
| Visual Basic | 
                         
                            コードのコピー
                         
                     | 
                
|---|---|
                        
Private Sub Button_Click(ByVal sender As System.Object, _   
 ByVal e As System.EventArgs) Handles Button.Click        
  Dim yf As C1.Win.C1Chart.YFunction = New C1.Win.C1Chart.YFunction()      
  yf.CustomFunction = New CustomFunction()     
  yf.MinX = -5       
  yf.MaxX = 5       
  yf.LineStyle.Color = Color.DarkGreen        
  yf.LineStyle.Thickness = 3       
  C1Chart1.ChartGroups(0).ChartData.FunctionsList.Add(yf)      
End Sub     
Public Class CustomFunction     
  Implements C1.Win.C1Chart.ISimpleFunction   
  Public Function Calculate(ByVal x As Double) As Double _    
   Implements C1.Win.C1Chart.ISimpleFunction.Calculate    
    Return -x * x * x     ' y = - x*x*x   
  End Function   
End Class
                     | 
                |
C# コードの書き方
| C# | 
                         
                            コードのコピー
                         
                     | 
                
|---|---|
                        
private void button_Click(object sender, System.EventArgs e)       
{      
  C1.Win.C1Chart.YFunction yf = new C1.Win.C1Chart.YFunction();     
  yf.MinX = -5;      
  yf.MaxX = 5;     
  yf.LineStyle.Color = Color.DarkGreen;      
  yf.LineStyle.Thickness = 2;     
  yf.CustomFunction = new CustomFunction();    
  c1Chart1.ChartGroups[0].ChartData.FunctionsList.Add( yf);     
}     
class CustomFunction : C1.Win.C1Chart.ISimpleFunction     
{     
  public double Calculate( double x)    
  {   
    return -x*x*x; // y = -x*x*x   
  }    
}
                     | 
                |