MindFusion.Charting Programmer's Guide

LineChart.CalculateFunction Property

See Also
 





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

Namespace: MindFusion.Charting.WebForms
Assembly: MindFusion.Charting.WebForms

 Syntax

C#  Copy Code

public CalculateFunctionDelegate CalculateFunction { get; set; }

Visual Basic  Copy Code

Public Property CalculateFunction As CalculateFunctionDelegate

 Property 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