MindFusion.Charting Programmer's Guide

CalculateFunctionDelegate Delegate

See Also
 





Invokes a custom function that calculates the values for the chart.

Namespace: MindFusion.Charting
Assembly: MindFusion.Charting

 Syntax

C#  Copy Code

public delegate float CalculateFunctionDelegate (
    float xValue,
    FunctionArgs e
)

Visual Basic  Copy Code

Public Delegate Function CalculateFunctionDelegate ( _
    xValue As Single, _
    e As FunctionArgs _
) As Single

 Parameters

xValue
the argument of the function, which is computed.
e

Argument of type FunctionArgs. It provides data for the event and has following members:

Member Name

Description

float StartValue

Specifies the beginning of the numerical interval in which the function is calculated.

float EndValue

Specifies the closing value of the numerical interval in which the function is calculated.

double FunctionDelta

Specifies the interval with which function values are calculated.

 Return Value

 Remarks

The delegate enables custom functions to be computed and drawn rather than settings numbers with XData and YData. The delegate's function argument specifies the numerical interval, in which the function is computed. In order to raise the CalculateFunction event, provide a method that calculates the value of a float argument and returns float result. Then, assign the method to an instance of the CalculateFunctionDelegate delegate.

 Example

The following example:

  • Creates a line chart
  • Sets the chart data with a delegate, which calculates the sine function in the interval [-3, 3];

C#  Copy Code

/// <summary>
/// The sine function.
/// </summary>
public float CalculateFunction(float xVal, MindFusion.Charting.FunctionArgs e)
{
 return (float)Math.Sin((double)xVal);
}

// ...

// Create the chart
MindFusion.Charting.LineChart chart = new MindFusion.Charting.LineChart(MindFusion.Charting.LineTypes.Line);

// Add the delegate
chart.CalculateFunction = new MindFusion.Charting.CalculateFunctionDelegate(CalculateFunction);

// Set the interval of calculation
chart.FunctionArguments = new MindFusion.Charting.FunctionArgs(-3, 3);

 See Also