2D Chart for WinForms | ComponentOne
Charting Data / Plotting Functions / Using a Code String to Define a Function / Formula Code Types
In This Topic
    Formula Code Types
    In This Topic

    For Formula code types, the CodeText property of a function class must contain code that calculates the value of a function using a parameter. The code should fit into a single line and represents the right hand side of an equation.

    To write code in Visual Basic

    Visual Basic
    Copy Code
    Dim yf As C1.Win.C1Chart.YFunction = New C1.Win.C1Chart.YFunction()        
    yf.CodeType = C1.Win.C1Chart.FunctionCodeTypeEnum.Formula        
    yf.CodeLanguage = C1.Win.C1Chart.FunctionCodeLanguageEnum.VB        
    yf.CodeText = "x*x"        
    yf.MinX = -5        
    yf.MaxX = 5        
    yf.LineStyle.Color = Color.Red        
    yf.LineStyle.Thickness = 3           
    C1Chart1.ChartGroups(0).ChartData.FunctionsList.Add(yf)
    

    To write code in C#

    C#
    Copy Code
    C1.Win.C1Chart.YFunction yf = new C1.Win.C1Chart.YFunction();                 
    yf.CodeType = C1.Win.C1Chart.FunctionCodeTypeEnum.Formula;        
    yf.CodeText = "x*x";                
    yf.MinX = -5;        
    yf.MaxX = 5;        
    yf.LineStyle.Color = Color.Red;        
    yf.LineStyle.Thickness = 3;                 
    c1Chart1.ChartGroups[0].ChartData.FunctionsList.Add(yf);
    
    See Also